Skip to content

Commit

Permalink
simplify unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
janelletavares committed Mar 17, 2023
1 parent b420f52 commit c9cedbb
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cmd/meroxa/root/apps/open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,44 +94,41 @@ func TestOpenAppExecution(t *testing.T) {

testCases := []struct {
desc string
path string
appArg string
appFlag string
errSubstring string
}{
{
desc: "Successfully open app link with arg",
appArg: "app-name",
path: filepath.Join("/tmp", uuid.New().String()),
},
{
desc: "Successfully open app link with flag",
path: filepath.Join("/tmp", uuid.New().String()),
},
{
desc: "Fail with bad path",
appFlag: "/tmp",
path: filepath.Join("/tmp", uuid.New().String()),
errSubstring: "could not find an app.json file on path",
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
os.Setenv("UNIT_TEST", "1")
path := filepath.Join("/tmp", uuid.New().String())
logger := log.NewTestLogger()
cc := &Init{}
cc.Logger(log.NewTestLogger())
cc.flags.Path = tc.path
cc.Logger(logger)
cc.flags.Path = path
cc.flags.Lang = "golang"
if tc.appArg != "" {
cc.args.appName = tc.appArg
if tc.appFlag == "" {
tc.appFlag = tc.path + "/" + tc.appArg
tc.appFlag = path + "/" + tc.appArg
}
} else {
cc.args.appName = "my-app"
if tc.appFlag == "" {
tc.appFlag = tc.path + "/my-app"
tc.appFlag = path + "/my-app"
}
}

Expand Down

0 comments on commit c9cedbb

Please sign in to comment.