-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathup_test.go
42 lines (39 loc) · 1.21 KB
/
up_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
package cage_test
import (
"context"
"testing"
cage "github.com/loilo-inc/canarycage"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)
func TestCage_Up(t *testing.T) {
t.Run("basic", func(t *testing.T) {
env := test.DefaultEnvars()
ctrl := gomock.NewController(t)
ctx, ecsMock, _, _ := test.Setup(ctrl, env, 1, "FARGATE")
delete(ctx.Services, env.Service)
cagecli := cage.NewCage(di.NewDomain(func(b *di.B) {
b.Set(key.Env, env)
b.Set(key.EcsCli, ecsMock)
}))
result, err := cagecli.Up(context.Background())
assert.Nil(t, err)
assert.NotNil(t, result.Service)
assert.NotNil(t, result.TaskDefinition)
})
t.Run("should show error if service exists", func(t *testing.T) {
env := test.DefaultEnvars()
ctrl := gomock.NewController(t)
_, ecsMock, _, _ := test.Setup(ctrl, env, 1, "FARGATE")
cagecli := cage.NewCage(di.NewDomain(func(b *di.B) {
b.Set(key.Env, env)
b.Set(key.EcsCli, ecsMock)
}))
result, err := cagecli.Up(context.Background())
assert.Nil(t, result)
assert.EqualError(t, err, "service 'service' already exists. Use 'cage rollout' instead")
})
}