@@ -78,7 +78,38 @@ func main() {
78
78
})
79
79
80
80
It ("runs nginx on port 80" , func () {
81
- runTest (subscriptionID )
81
+ aciContext := store.AciContext {
82
+ SubscriptionID : subscriptionID ,
83
+ Location : location ,
84
+ ResourceGroup : resourceGroupName ,
85
+ }
86
+ createStorageAccount (aciContext , testStorageAccountName )
87
+ defer deleteStorageAccount (aciContext )
88
+ keys := getStorageKeys (aciContext , testStorageAccountName )
89
+ firstKey := * keys [0 ].Value
90
+ credential , u := createFileShare (firstKey , testShareName )
91
+ uploadFile (credential , u .String (), testFileName , testFileContent )
92
+
93
+ mountTarget := "/usr/share/nginx/html"
94
+ output := NewDockerCommand ("run" , "nginx" ,
95
+ "-v" , fmt .Sprintf ("%s:%s@%s:%s" ,
96
+ testStorageAccountName , firstKey , testShareName , mountTarget ),
97
+ "-p" , "80:80" ,
98
+ "--name" , testContainerName ).ExecOrDie ()
99
+ Expect (output ).To (Equal (testContainerName + "\n " ))
100
+ output = NewDockerCommand ("ps" ).ExecOrDie ()
101
+ lines := Lines (output )
102
+ Expect (len (lines )).To (Equal (2 ))
103
+
104
+ containerFields := Columns (lines [1 ])
105
+ Expect (containerFields [1 ]).To (Equal ("nginx" ))
106
+ Expect (containerFields [2 ]).To (Equal ("Running" ))
107
+ exposedIP := containerFields [3 ]
108
+ Expect (exposedIP ).To (ContainSubstring (":80->80/tcp" ))
109
+
110
+ publishedURL := strings .ReplaceAll (exposedIP , "->80/tcp" , "" )
111
+ output = NewCommand ("curl" , publishedURL ).ExecOrDie ()
112
+ Expect (output ).To (ContainSubstring (testFileContent ))
82
113
})
83
114
84
115
It ("removes container nginx" , func () {
@@ -181,41 +212,6 @@ func uploadFile(credential azfile.SharedKeyCredential, baseURL, fileName, fileCo
181
212
Expect (err ).To (BeNil ())
182
213
}
183
214
184
- func runTest (subscriptionID string ) {
185
- aciContext := store.AciContext {
186
- SubscriptionID : subscriptionID ,
187
- Location : location ,
188
- ResourceGroup : resourceGroupName ,
189
- }
190
- createStorageAccount (aciContext , testStorageAccountName )
191
- defer deleteStorageAccount (aciContext )
192
- keys := getStorageKeys (aciContext , testStorageAccountName )
193
- firstKey := * keys [0 ].Value
194
- credential , u := createFileShare (firstKey , testShareName )
195
- uploadFile (credential , u .String (), testFileName , testFileContent )
196
-
197
- mountTarget := "/usr/share/nginx/html"
198
- output := NewDockerCommand ("run" , "nginx" ,
199
- "-v" , fmt .Sprintf ("%s:%s@%s:%s" ,
200
- testStorageAccountName , firstKey , testShareName , mountTarget ),
201
- "-p" , "80:80" ,
202
- "--name" , testContainerName ).ExecOrDie ()
203
- Expect (output ).To (Equal (testContainerName + "\n " ))
204
- output = NewDockerCommand ("ps" ).ExecOrDie ()
205
- lines := Lines (output )
206
- Expect (len (lines )).To (Equal (2 ))
207
-
208
- containerFields := Columns (lines [1 ])
209
- Expect (containerFields [1 ]).To (Equal ("nginx" ))
210
- Expect (containerFields [2 ]).To (Equal ("Running" ))
211
- exposedIP := containerFields [3 ]
212
- Expect (exposedIP ).To (ContainSubstring (":80->80/tcp" ))
213
-
214
- publishedURL := strings .ReplaceAll (exposedIP , "->80/tcp" , "" )
215
- output = NewCommand ("curl" , publishedURL ).ExecOrDie ()
216
- Expect (output ).To (ContainSubstring (testFileContent ))
217
- }
218
-
219
215
func setupTestResourceGroup (groupName string ) {
220
216
log .Println ("Creating resource group " + resourceGroupName )
221
217
ctx := context .TODO ()
0 commit comments