-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_test.go
42 lines (32 loc) · 881 Bytes
/
config_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 lanes_test
import (
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/codekoala/go-aws-lanes"
)
func TestLoadConfigBytes(t *testing.T) {
envVar := "LANES_PROFILE"
in := []byte(`profile: foo`)
os.Unsetenv(envVar)
out, err := lanes.LoadConfigBytes([]byte{})
assert.NotNil(t, err)
out, err = lanes.LoadConfigBytes(in)
assert.Nil(t, err)
assert.Equal(t, out.Profile, "foo")
os.Setenv(envVar, "test")
out, err = lanes.LoadConfigBytes(in)
assert.Nil(t, err)
assert.Equal(t, out.Profile, "test")
}
func TestConfigWriteBytes(t *testing.T) {
c := &lanes.Config{Profile: "demo"}
out, err := c.WriteBytes()
assert.Nil(t, err)
assert.Equal(t, out, []byte("profile: demo\n"))
}
func TestConfigGetProfilePath(t *testing.T) {
c := &lanes.Config{Profile: "demo"}
assert.True(t, strings.HasSuffix(c.GetProfilePath(), "/demo.yml"))
}