Skip to content

Commit

Permalink
feat: Add dev-test-send-line command to Makefile and script/run.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
peterxcli committed Feb 27, 2024
1 parent 7283d91 commit 006691b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
./script/run.sh dev sync

dev-test-send-line: ## Send a Event to the line bot
./script/run.sh dev test-send-line
41 changes: 41 additions & 0 deletions cmd/test-send-line/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
4 changes: 3 additions & 1 deletion script/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 006691b

Please sign in to comment.