@@ -16,16 +16,16 @@ type CommanderTestSuite struct {
1616 migratorMock * migrator.Mock
1717 instance Commander
1818 expectedErr error
19- set * flag.FlagSet
20- c * cli.Context
19+ flagSet * flag.FlagSet
20+ ctx * cli.Context
2121}
2222
2323func (suite * CommanderTestSuite ) SetupTest () {
2424 suite .migratorMock = & migrator.Mock {}
2525 suite .instance = New (suite .migratorMock )
2626 suite .expectedErr = errors .New ("failure" )
27- suite .set = flag .NewFlagSet ("test" , 0 )
28- suite .c = cli .NewContext (nil , suite .set , nil )
27+ suite .flagSet = flag .NewFlagSet ("test" , 0 )
28+ suite .ctx = cli .NewContext (nil , suite .flagSet , nil )
2929}
3030
3131func Test_Commander_TestSuite (t * testing.T ) {
@@ -45,7 +45,7 @@ func (suite *CommanderTestSuite) Test_New_ReturnsInstance_InCaseOfSuccess() {
4545
4646func (suite * CommanderTestSuite ) Test_Create_ReturnsError_InCaseOfMissingArgument () {
4747 // Act
48- err := suite .instance .Create (suite .c )
48+ err := suite .instance .Create (suite .ctx )
4949
5050 // Assert
5151 suite .NotNil (err )
@@ -54,12 +54,12 @@ func (suite *CommanderTestSuite) Test_Create_ReturnsError_InCaseOfMissingArgumen
5454
5555func (suite * CommanderTestSuite ) Test_Create_ReturnsError_InCaseOfMissingFlag () {
5656 // Arrange
57- if err := suite .set .Parse ([]string {"create_table_users" }); err != nil {
57+ if err := suite .flagSet .Parse ([]string {"create_table_users" }); err != nil {
5858 suite .FailNow (err .Error ())
5959 }
6060
6161 // Act
62- err := suite .instance .Create (suite .c )
62+ err := suite .instance .Create (suite .ctx )
6363
6464 // Assert
6565 suite .NotNil (err )
@@ -68,15 +68,15 @@ func (suite *CommanderTestSuite) Test_Create_ReturnsError_InCaseOfMissingFlag()
6868
6969func (suite * CommanderTestSuite ) Test_Create_ReturnsError_InCaseOfMigratorError () {
7070 // Arrange
71- suite .set .String ("path" , "" , "" )
72- if err := suite .set .Parse ([]string {"--path" , "testdata" , "create_table_users" }); err != nil {
71+ suite .flagSet .String ("path" , "" , "" )
72+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "create_table_users" }); err != nil {
7373 suite .FailNow (err .Error ())
7474 }
7575 pair := & file.Pair {}
7676 suite .migratorMock .On ("Create" , "create_table_users" , "testdata" ).Return (pair , suite .expectedErr ).Once ()
7777
7878 // Act
79- err := suite .instance .Create (suite .c )
79+ err := suite .instance .Create (suite .ctx )
8080
8181 // Assert
8282 suite .NotNil (err )
@@ -85,23 +85,23 @@ func (suite *CommanderTestSuite) Test_Create_ReturnsError_InCaseOfMigratorError(
8585
8686func (suite * CommanderTestSuite ) Test_Create_ReturnsNil_InCaseOfSuccess () {
8787 // Arrange
88- suite .set .String ("path" , "" , "" )
89- if err := suite .set .Parse ([]string {"--path" , "testdata" , "create_table_users" }); err != nil {
88+ suite .flagSet .String ("path" , "" , "" )
89+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "create_table_users" }); err != nil {
9090 suite .FailNow (err .Error ())
9191 }
9292 pair := & file.Pair {}
9393 suite .migratorMock .On ("Create" , "create_table_users" , "testdata" ).Return (pair , nil ).Once ()
9494
9595 // Act
96- err := suite .instance .Create (suite .c )
96+ err := suite .instance .Create (suite .ctx )
9797
9898 // Assert
9999 suite .Nil (err )
100100}
101101
102102func (suite * CommanderTestSuite ) Test_Up_ReturnError_InCaseOfMissingPath () {
103103 // Act
104- err := suite .instance .Up (suite .c )
104+ err := suite .instance .Up (suite .ctx )
105105
106106 // Assert
107107 suite .NotNil (err )
@@ -110,13 +110,13 @@ func (suite *CommanderTestSuite) Test_Up_ReturnError_InCaseOfMissingPath() {
110110
111111func (suite * CommanderTestSuite ) Test_Up_ReturnError_InCaseOfMissingURL () {
112112 // Arrange
113- suite .set .String ("path" , "" , "" )
114- if err := suite .set .Parse ([]string {"--path" , "testdata" }); err != nil {
113+ suite .flagSet .String ("path" , "" , "" )
114+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" }); err != nil {
115115 suite .FailNow (err .Error ())
116116 }
117117
118118 // Act
119- err := suite .instance .Up (suite .c )
119+ err := suite .instance .Up (suite .ctx )
120120
121121 // Assert
122122 suite .NotNil (err )
@@ -125,15 +125,15 @@ func (suite *CommanderTestSuite) Test_Up_ReturnError_InCaseOfMissingURL() {
125125
126126func (suite * CommanderTestSuite ) Test_Up_ReturnError_InCaseOfMigratorError () {
127127 // Arrange
128- suite .set .String ("path" , "" , "" )
129- suite .set .String ("url" , "" , "" )
130- if err := suite .set .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
128+ suite .flagSet .String ("path" , "" , "" )
129+ suite .flagSet .String ("url" , "" , "" )
130+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
131131 suite .FailNow (err .Error ())
132132 }
133133 suite .migratorMock .On ("Migrate" , "testdata" , "connectionurl" , true , 0 ).Return (suite .expectedErr ).Once ()
134134
135135 // Act
136- err := suite .instance .Up (suite .c )
136+ err := suite .instance .Up (suite .ctx )
137137
138138 // Assert
139139 suite .NotNil (err )
@@ -142,14 +142,14 @@ func (suite *CommanderTestSuite) Test_Up_ReturnError_InCaseOfMigratorError() {
142142
143143func (suite * CommanderTestSuite ) Test_Up_ReturnError_InCaseOfInvalidArgument () {
144144 // Arrange
145- suite .set .String ("path" , "" , "" )
146- suite .set .String ("url" , "" , "" )
147- if err := suite .set .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" , "foobar" }); err != nil {
145+ suite .flagSet .String ("path" , "" , "" )
146+ suite .flagSet .String ("url" , "" , "" )
147+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" , "foobar" }); err != nil {
148148 suite .FailNow (err .Error ())
149149 }
150150
151151 // Act
152- err := suite .instance .Up (suite .c )
152+ err := suite .instance .Up (suite .ctx )
153153
154154 // Assert
155155 suite .NotNil (err )
@@ -158,39 +158,39 @@ func (suite *CommanderTestSuite) Test_Up_ReturnError_InCaseOfInvalidArgument() {
158158
159159func (suite * CommanderTestSuite ) Test_Up_ReturnNil_InCaseOfSuccess () {
160160 // Arrange
161- suite .set .String ("path" , "" , "" )
162- suite .set .String ("url" , "" , "" )
163- if err := suite .set .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
161+ suite .flagSet .String ("path" , "" , "" )
162+ suite .flagSet .String ("url" , "" , "" )
163+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
164164 suite .FailNow (err .Error ())
165165 }
166166 suite .migratorMock .On ("Migrate" , "testdata" , "connectionurl" , true , 0 ).Return (nil ).Once ()
167167
168168 // Act
169- err := suite .instance .Up (suite .c )
169+ err := suite .instance .Up (suite .ctx )
170170
171171 // Assert
172172 suite .Nil (err )
173173}
174174
175175func (suite * CommanderTestSuite ) Test_Up_ReturnNil_InCaseOfArgumentN () {
176176 // Arrange
177- suite .set .String ("path" , "" , "" )
178- suite .set .String ("url" , "" , "" )
179- if err := suite .set .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" , "10" }); err != nil {
177+ suite .flagSet .String ("path" , "" , "" )
178+ suite .flagSet .String ("url" , "" , "" )
179+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" , "10" }); err != nil {
180180 suite .FailNow (err .Error ())
181181 }
182182 suite .migratorMock .On ("Migrate" , "testdata" , "connectionurl" , true , 10 ).Return (nil ).Once ()
183183
184184 // Act
185- err := suite .instance .Up (suite .c )
185+ err := suite .instance .Up (suite .ctx )
186186
187187 // Assert
188188 suite .Nil (err )
189189}
190190
191191func (suite * CommanderTestSuite ) Test_Down_ReturnError_InCaseOfMissingPath () {
192192 // Act
193- err := suite .instance .Down (suite .c )
193+ err := suite .instance .Down (suite .ctx )
194194
195195 // Assert
196196 suite .NotNil (err )
@@ -199,13 +199,13 @@ func (suite *CommanderTestSuite) Test_Down_ReturnError_InCaseOfMissingPath() {
199199
200200func (suite * CommanderTestSuite ) Test_Down_ReturnError_InCaseOfMissingURL () {
201201 // Arrange
202- suite .set .String ("path" , "" , "" )
203- if err := suite .set .Parse ([]string {"--path" , "testdata" }); err != nil {
202+ suite .flagSet .String ("path" , "" , "" )
203+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" }); err != nil {
204204 suite .FailNow (err .Error ())
205205 }
206206
207207 // Act
208- err := suite .instance .Down (suite .c )
208+ err := suite .instance .Down (suite .ctx )
209209
210210 // Assert
211211 suite .NotNil (err )
@@ -214,15 +214,15 @@ func (suite *CommanderTestSuite) Test_Down_ReturnError_InCaseOfMissingURL() {
214214
215215func (suite * CommanderTestSuite ) Test_Down_ReturnError_InCaseOfMigratorError () {
216216 // Arrange
217- suite .set .String ("path" , "" , "" )
218- suite .set .String ("url" , "" , "" )
219- if err := suite .set .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
217+ suite .flagSet .String ("path" , "" , "" )
218+ suite .flagSet .String ("url" , "" , "" )
219+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
220220 suite .FailNow (err .Error ())
221221 }
222222 suite .migratorMock .On ("Migrate" , "testdata" , "connectionurl" , false , 0 ).Return (suite .expectedErr ).Once ()
223223
224224 // Act
225- err := suite .instance .Down (suite .c )
225+ err := suite .instance .Down (suite .ctx )
226226
227227 // Assert
228228 suite .NotNil (err )
@@ -231,15 +231,15 @@ func (suite *CommanderTestSuite) Test_Down_ReturnError_InCaseOfMigratorError() {
231231
232232func (suite * CommanderTestSuite ) Test_Down_ReturnNil_InCaseOfSuccess () {
233233 // Arrange
234- suite .set .String ("path" , "" , "" )
235- suite .set .String ("url" , "" , "" )
236- if err := suite .set .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
234+ suite .flagSet .String ("path" , "" , "" )
235+ suite .flagSet .String ("url" , "" , "" )
236+ if err := suite .flagSet .Parse ([]string {"--path" , "testdata" , "--url" , "connectionurl" }); err != nil {
237237 suite .FailNow (err .Error ())
238238 }
239239 suite .migratorMock .On ("Migrate" , "testdata" , "connectionurl" , false , 0 ).Return (nil ).Once ()
240240
241241 // Act
242- err := suite .instance .Down (suite .c )
242+ err := suite .instance .Down (suite .ctx )
243243
244244 // Assert
245245 suite .Nil (err )
0 commit comments