-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollout_test.go
More file actions
49 lines (46 loc) · 2.13 KB
/
Copy pathrollout_test.go
File metadata and controls
49 lines (46 loc) · 2.13 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
package commands_test
import (
"context"
"fmt"
"strings"
"testing"
"github.com/loilo-inc/canarycage/v6/types"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)
func TestRollOut(t *testing.T) {
t.Run("basic", func(t *testing.T) {
app, cagecli := setup(t, strings.NewReader(stdinService))
cagecli.EXPECT().RollOut(gomock.Any(), &types.RollOutInput{}).Return(&types.RollOutResult{}, nil)
err := app.Run(context.Background(), []string{"cage", "rollout", "--region", "ap-notheast-1", "../../../fixtures"})
assert.NoError(t, err)
})
t.Run("basic/ci", func(t *testing.T) {
app, cagecli := setup(t, nil)
cagecli.EXPECT().RollOut(gomock.Any(), &types.RollOutInput{}).Return(&types.RollOutResult{}, nil)
err := app.Run(context.Background(), []string{"cage", "--ci", "rollout", "--region", "ap-notheast-1", "../../../fixtures"})
assert.NoError(t, err)
})
t.Run("basic/update-service", func(t *testing.T) {
app, cagecli := setup(t, strings.NewReader(stdinService))
cagecli.EXPECT().RollOut(gomock.Any(), &types.RollOutInput{UpdateService: true}).Return(&types.RollOutResult{}, nil)
err := app.Run(context.Background(), []string{"cage", "rollout", "--region", "ap-notheast-1", "--updateService", "../../../fixtures"})
assert.NoError(t, err)
})
t.Run("missing args", func(t *testing.T) {
app, _ := setup(t, nil)
err := app.Run(context.Background(), []string{"cage", "rollout", "--region", "ap-notheast-1"})
assert.EqualError(t, err, "invalid number of arguments. expected at least 1")
})
t.Run("reading stdin error", func(t *testing.T) {
app, _ := setup(t, &errorReader{})
err := app.Run(context.Background(), []string{"cage", "rollout", "--region", "ap-notheast-1", "../../../fixtures"})
assert.EqualError(t, err, "failed to read from stdin: EOF")
})
t.Run("error", func(t *testing.T) {
app, cagecli := setup(t, strings.NewReader(stdinService))
cagecli.EXPECT().RollOut(gomock.Any(), &types.RollOutInput{}).Return(&types.RollOutResult{}, fmt.Errorf("error"))
err := app.Run(context.Background(), []string{"cage", "rollout", "--region", "ap-notheast-1", "../../../fixtures"})
assert.EqualError(t, err, "error")
})
}