Skip to content

Commit

Permalink
FIx running only several test names
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriiklymiuk committed Feb 20, 2023
1 parent e3a711a commit e37cd35
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var testCmd = &cobra.Command{
Run: runTest,
}

var EnvItemsFromFlag []string

func init() {
rootCmd.AddCommand(testCmd)

Expand All @@ -35,6 +37,20 @@ none - will ignore all services run test.
By default all services are included and test are run on them.
`,
)

testCmd.PersistentFlags().StringSliceVarP(
&EnvItemsFromFlag,
"env",
"",
[]string{},
`Slice of test names to choose from.
If you provide at least 1 env here, than corgi will choose only to run these test names, while ignoring all others.
(--env local,dev,prod)
By default all tests are included to run.
`,
)
}

func runTest(cmd *cobra.Command, _ []string) {
Expand All @@ -46,6 +62,9 @@ func runTest(cmd *cobra.Command, _ []string) {
for _, service := range corgi.Services {
fmt.Println(art.BlueColor, "🐶 TESTING SERVICE", service.ServiceName, art.WhiteColor)
for _, testServiceCmd := range service.Test {
if !utils.IsServiceIncludedInFlag(EnvItemsFromFlag, testServiceCmd.Name) {
continue
}
testService(testServiceCmd, service.Path)
}
}
Expand Down

0 comments on commit e37cd35

Please sign in to comment.