forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_test.go
More file actions
50 lines (42 loc) · 1.11 KB
/
init_test.go
File metadata and controls
50 lines (42 loc) · 1.11 KB
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
package integration
// Basic imports
import (
"context"
"os"
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
clicmd "github.com/supabase/cli/cmd"
"github.com/supabase/cli/internal/utils"
)
type InitTestSuite struct {
suite.Suite
tempDir string
cmd *cobra.Command
}
// test functions
func (suite *InitTestSuite) TestInit() {
// init supabase
init, _, err := suite.cmd.Find([]string{"init"})
require.NoError(suite.T(), err)
init.SetContext(context.Background())
require.NoError(suite.T(), init.RunE(init, []string{}))
// check if init dir exists
_, err = os.Stat(utils.ConfigPath)
require.NoError(suite.T(), err)
}
// hooks
func (suite *InitTestSuite) SetupTest() {
// init cli
suite.cmd = clicmd.GetRootCmd()
suite.tempDir = NewTempDir(Logger, TempDir)
}
func (suite *InitTestSuite) TeardownTest() {
require.NoError(suite.T(), os.Chdir(TempDir))
}
// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestInitTestSuite(t *testing.T) {
suite.Run(t, new(InitTestSuite))
}