Skip to content

Commit 544bee4

Browse files
author
Chris Gilmer
committed
Start using testing suites to separate code
1 parent 5c8df8e commit 544bee4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

cmd/cli_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/aws/aws-sdk-go/aws/endpoints"
1010
"github.com/spf13/viper"
11-
"github.com/stretchr/testify/assert"
1211
"github.com/stretchr/testify/suite"
1312
)
1413

@@ -96,20 +95,21 @@ func (suite *cliTestSuite) TestCheckRegion() {
9695
}
9796
}
9897

99-
func TestCheckProfileName(t *testing.T) {
98+
func (suite *cliTestSuite) TestCheckProfileName() {
99+
suite.Setup()
100100
testValues := []string{
101101
"test-id",
102102
"test-id1",
103103
"test-id_1",
104104
}
105105
for _, testValue := range testValues {
106-
assert.NoError(t, checkProfileName(testValue))
106+
suite.NoError(checkProfileName(testValue))
107107
}
108108
testValuesWithErrors := []string{
109109
"",
110110
}
111111
for _, testValue := range testValuesWithErrors {
112-
assert.Error(t, checkProfileName(testValue))
112+
suite.Error(checkProfileName(testValue))
113113
}
114114
}
115115

@@ -132,17 +132,17 @@ func (suite *cliTestSuite) TestCheckAccountID() {
132132
}
133133
}
134134

135-
func TestCheckProfileAccount(t *testing.T) {
136-
v := viper.New()
135+
func (suite *cliTestSuite) TestCheckProfileAccount() {
136+
suite.Setup()
137137

138138
testValues := [][]string{
139139
{"test-id:012345678901"},
140140
{"test-id1:012345678901", "test-id2:012345678901", "test-id3:012345678901"},
141141
}
142142
for _, testValue := range testValues {
143-
v.Set(AWSProfileAccountFlag, testValue)
144-
err := checkProfileAccount(v)
145-
assert.NoError(t, err)
143+
suite.viper.Set(AWSProfileAccountFlag, testValue)
144+
err := checkProfileAccount(suite.viper)
145+
suite.NoError(err)
146146
}
147147
testValuesWithErrors := [][]string{
148148
{"test-id:0123456789011"},
@@ -151,9 +151,9 @@ func TestCheckProfileAccount(t *testing.T) {
151151
{"test-id012345678901"},
152152
}
153153
for _, testValue := range testValuesWithErrors {
154-
v.Set(AWSProfileAccountFlag, testValue)
155-
err := checkProfileAccount(v)
156-
assert.Error(t, err)
154+
suite.viper.Set(AWSProfileAccountFlag, testValue)
155+
err := checkProfileAccount(suite.viper)
156+
suite.Error(err)
157157
}
158158
}
159159

0 commit comments

Comments
 (0)