-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathtest.go
56 lines (49 loc) · 1.45 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package cmd
import (
"os"
"os/signal"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/supabase/cli/internal/test/new"
"github.com/supabase/cli/internal/utils"
)
var (
testCmd = &cobra.Command{
GroupID: groupLocalDev,
Use: "test",
Short: "Run tests on local Supabase containers",
}
testDbCmd = &cobra.Command{
Use: "db [path] ...",
Short: dbTestCmd.Short,
RunE: dbTestCmd.RunE,
}
template = utils.EnumFlag{
Allowed: []string{new.TemplatePgTAP},
Value: new.TemplatePgTAP,
}
testNewCmd = &cobra.Command{
Use: "new <name>",
Short: "Create a new test file",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt)
return new.Run(ctx, args[0], template.Value, afero.NewOsFs())
},
}
)
func init() {
// Build db command
dbFlags := testDbCmd.Flags()
dbFlags.String("db-url", "", "Tests the database specified by the connection string (must be percent-encoded).")
dbFlags.Bool("linked", false, "Runs pgTAP tests on the linked project.")
dbFlags.Bool("local", true, "Runs pgTAP tests on the local database.")
testDbCmd.MarkFlagsMutuallyExclusive("db-url", "linked", "local")
testCmd.AddCommand(testDbCmd)
// Build new command
newFlags := testNewCmd.Flags()
newFlags.VarP(&template, "template", "t", "Template framework to generate.")
testCmd.AddCommand(testNewCmd)
// Build test command
rootCmd.AddCommand(testCmd)
}