diff --git a/Makefile b/Makefile index 6bf0583..aaea850 100644 --- a/Makefile +++ b/Makefile @@ -60,4 +60,7 @@ prod-up: ## Start the container for production ./script/run.sh prod start dev-sync: ## Load the dev environment variables - ./script/run.sh dev sync \ No newline at end of file + ./script/run.sh dev sync + +dev-test-send-line: ## Send a Event to the line bot + ./script/run.sh dev test-send-line \ No newline at end of file diff --git a/cmd/test-send-line/main.go b/cmd/test-send-line/main.go new file mode 100644 index 0000000..f20ef2f --- /dev/null +++ b/cmd/test-send-line/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "bikefest/pkg/bootstrap" + "bikefest/pkg/service" + "context" + "fmt" +) + +func main() { + // init config + app := bootstrap.App() + + // init services + // userService := service.NewUserService(app.Conn, app.Cache) + notifyService := service.NewAsynqService(app.AsynqClient, app.AsynqInspector, app.Env) + ctx := context.Background() + + fmt.Println("Enter your user ID: ") + var userID string + _, err := fmt.Scan(&userID) + if err != nil { + panic(err) + } + fmt.Println("Enter your event ID: ") + var eventID string + _, err = fmt.Scan(&eventID) + if err != nil { + panic(err) + } + println("Enter your event start time: ") + var eventStartTime string + _, err = fmt.Scan(&eventStartTime) + if err != nil { + panic(err) + } + err = notifyService.EnqueueEventNotification(ctx, userID, eventID, eventStartTime) + if err != nil { + panic(err) + } +} diff --git a/script/run.sh b/script/run.sh index 5ce1216..9e2df7a 100755 --- a/script/run.sh +++ b/script/run.sh @@ -74,7 +74,7 @@ case "$action" in fi ;; - migrate|run|serve|test|bot|sync) + migrate|run|serve|test|bot|sync|test-send-line) export_env $mode if [ "$action" = "migrate" ]; then go run ./cmd/migrate/migrate.go @@ -88,6 +88,8 @@ case "$action" in go test -v -cover ./... elif [ "$action" = "sync" ]; then go run ./cmd/sync/main.go + elif [ "$action" = "test-send-line" ]; then + go run ./cmd/test-send-line/main.go else echo "Error: Invalid command. Choose from (generate | migrate | run | serve)" exit 1