-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquery_lambda_test.go
82 lines (61 loc) · 2.03 KB
/
query_lambda_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//go:build integration
package cmd_test
import (
"fmt"
"regexp"
"testing"
"github.com/stretchr/testify/suite"
"github.com/rockset/cli/cmd"
"github.com/rockset/cli/internal/test"
)
type QueryLambdaSuite struct {
suite.Suite
name string
version string
}
func TestQueryLambda(t *testing.T) {
s := QueryLambdaSuite{name: "dummy"}
suite.Run(t, &s)
}
func (s *QueryLambdaSuite) Test_0_Create() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "create", "ql", "--sql", "testdata/query_lambda.sql", "--wait", s.name)
re := regexp.MustCompile(`created query lambda commons\.\w+:(\w+)\s`)
m := re.FindStringSubmatch(out.String())
s.Require().NotNil(m, "no regexp match")
s.version = m[1]
}
func (s *QueryLambdaSuite) Test_1_Get() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "get", "ql", "--version", s.version, s.name)
s.NotEmpty(out.String())
}
func (s *QueryLambdaSuite) Test_2_List() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "list", "ql")
s.NotEmpty(out.String())
}
func (s *QueryLambdaSuite) Test_3_Execute() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "execute", "ql", "--version", s.version, s.name)
s.NotEmpty(out.String())
}
func (s *QueryLambdaSuite) Test_4_Update() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "update", "ql", "--sql", "testdata/query_lambda_updated.sql", "--wait", s.name)
re := regexp.MustCompile(`updated query lambda commons\.\w+:(\w+)\s`)
m := re.FindStringSubmatch(out.String())
s.Require().NotNil(m, "no regexp match")
s.version = m[1]
}
func (s *QueryLambdaSuite) Test_5_Execute() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "execute", "ql", "--version", s.version, s.name)
s.NotEmpty(out.String())
}
// TODO test invoking using a tag too
func (s *QueryLambdaSuite) Test_6_Delete() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "delete", "ql", s.name)
s.Equal(fmt.Sprintf("deleted query lambda %s in commons\n", s.name), out.String())
}