forked from spezam/eventbridge-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration_test.go
73 lines (63 loc) · 1.58 KB
/
integration_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
// +build integration
package main
import (
"flag"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli/v2"
)
func Test_integration(t *testing.T) {
tests := []struct {
name string
eventbusname string
eventpattern string
inputevent string
err bool
}{
{
name: "successfull",
eventbusname: "default",
eventpattern: "file://testdata/eventpattern.json",
inputevent: "file://testdata/event_ci_success.json",
err: false,
},
{
name: "successfull from sam",
eventbusname: "default",
eventpattern: "sam://testdata/template.yaml/BetaFunction",
inputevent: "file://testdata/event_ci_success.json",
err: false,
},
{
name: "failing",
eventbusname: "default",
eventpattern: "file://testdata/eventpattern.json",
inputevent: "file://testdata/event_ci_fail.json",
err: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// override global runID as the value doesn't refresh for each iteration
runID = uuid.New().String()
app := cli.NewApp()
// flags
set := flag.NewFlagSet("integration-test", 0)
set.String("eventbusname", test.eventbusname, "")
set.String("eventpattern", test.eventpattern, "")
set.Bool("prettyjson", true, "")
// ci flags
set.Int64("timeout", 8, "")
set.String("inputevent", test.inputevent, "")
c := cli.NewContext(app, set, nil)
c.Command.Name = "ci"
err := run(c)
if test.err {
assert.Error(t, err)
return
}
assert.NoError(t, err)
})
}
}