-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/mantil-io/mantil.go/pkg/shell" | ||
"github.com/mantil-io/mantil/internal/cli/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var testCmd = &cobra.Command{ | ||
Use: "test", | ||
Short: "Run project integration tests", | ||
Long: `Run project integration tests | ||
Project integration tests are pure Go test in [project-root]/test folder. | ||
Mantil sets MANTIL_API_URL environment variable to point to the current | ||
project api url and runs tests with 'go test -v'. | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
config, path, _ := localData() | ||
run := cmd.Flag("run").Value.String() | ||
shellArgs := []string{"go", "test", "-v"} | ||
if run != "" { | ||
shellArgs = append(shellArgs, "--run", run) | ||
} | ||
err := shell.Exec(shell.ExecOptions{ | ||
Env: []string{"MANTIL_API_URL=" + config.ApiURL}, | ||
Args: shellArgs, | ||
WorkDir: path + "/test", | ||
Logger: log.Info, | ||
ShowShellCmd: false, | ||
}) | ||
if err != nil { | ||
log.Error(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
testCmd.Flags().StringP("run", "r", "", "run only tests with this pattern in name") | ||
rootCmd.AddCommand(testCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters