Skip to content

Commit

Permalink
Add some tests to the main file
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Dec 7, 2024
1 parent 046ad0a commit 4d98533
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/init_env/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ func Main(envPath string) {
err := godotenv.Load(envPath)

if err != nil {
logger.Fatal("No .env file found. Please copy it from the .env.example and enter your credentials")
logger.Fatal("No %s file found. Please copy it from the .env.example and enter your credentials", envPath)
}
}
19 changes: 19 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"os"
"testing"
)

func TestMain(t *testing.T) {
setArgs("migrate:db", "--reset", "--env-file=.env.test")
main()

setArgs("remote:sync", "--reset", "--env-file=.env.test")
main()
}

func setArgs(args ...string) {
os.Args = []string{os.Args[0]}
os.Args = append(os.Args, args...)
}

0 comments on commit 4d98533

Please sign in to comment.