Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 762f462

Browse files
committed
Get "run" test back to main function
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 70bcdca commit 762f462

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

tests/aci-e2e/e2e-aci.go

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,38 @@ func main() {
7878
})
7979

8080
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))
82113
})
83114

84115
It("removes container nginx", func() {
@@ -181,41 +212,6 @@ func uploadFile(credential azfile.SharedKeyCredential, baseURL, fileName, fileCo
181212
Expect(err).To(BeNil())
182213
}
183214

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-
219215
func setupTestResourceGroup(groupName string) {
220216
log.Println("Creating resource group " + resourceGroupName)
221217
ctx := context.TODO()

0 commit comments

Comments
 (0)