Skip to content

Commit 0265267

Browse files
committed
Add tests for volumes, secrets and configs
- Volumes - Secrets - Configs are implemented but disabled because docker-compose does not support that yet Signed-off-by: Ulysses Souza <[email protected]>
1 parent f703b6d commit 0265267

File tree

8 files changed

+71
-6
lines changed

8 files changed

+71
-6
lines changed

compliance_test.go

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import (
88
)
99

1010
const (
11-
defaultPingEntrypoint = "http://localhost:8080/ping"
12-
targetUrl = "target:8080/ping"
13-
defaultTargetUrl = defaultPingEntrypoint + "?address=" + targetUrl
11+
pingEntrypoint = "http://localhost:8080/ping"
12+
pingTargetUrl = "target:8080/ping"
13+
pingUrl = pingEntrypoint + "?address=" + pingTargetUrl
14+
15+
volumefileEntrypoint = "http://localhost:8080/volumefile"
16+
volumeUrl = volumefileEntrypoint + "?filename="
1417
)
1518

1619
func TestSimpleLifecycle(t *testing.T) {
@@ -23,7 +26,7 @@ func TestSimpleLifecycle(t *testing.T) {
2326
func TestSimpleNetwork(t *testing.T) {
2427
h := TestHelper{T: t, testDir: "simple_network"}
2528
h.testUpDown(func(t *testing.T) {
26-
actual := getHttpBody(t, defaultTargetUrl)
29+
actual := getHttpBody(t, pingUrl)
2730
assert.Assert(t, actual == "{\"response\":\"PONG FROM TARGET\"}\n")
2831
})
2932
}
@@ -39,7 +42,32 @@ func TestSimpleNetworkFail(t *testing.T) {
3942
func TestDifferentNetworks(t *testing.T) {
4043
h := TestHelper{T: t, testDir: "different_networks"}
4144
h.testUpDown(func(t *testing.T) {
42-
actual := getHttpBody(t, defaultTargetUrl)
45+
actual := getHttpBody(t, pingUrl)
4346
assert.Assert(t, actual == "{\"response\":\"Could not reach address: target:8080/ping\"}\n")
4447
})
4548
}
49+
50+
func TestVolumeFile(t *testing.T) {
51+
h := TestHelper{T: t, testDir: "simple_volume"}
52+
h.testUpDown(func(t *testing.T) {
53+
actual := getHttpBody(t, volumeUrl+"test_volume.txt")
54+
assert.Assert(t, actual == "{\"response\":\"MYVOLUME\"}\n")
55+
})
56+
}
57+
58+
func TestSecretFile(t *testing.T) {
59+
h := TestHelper{T: t, testDir: "simple_secretfile"}
60+
h.testUpDown(func(t *testing.T) {
61+
actual := getHttpBody(t, volumeUrl+"test_secret.txt")
62+
assert.Assert(t, actual == "{\"response\":\"MYSECRET\"}\n")
63+
})
64+
}
65+
66+
// Ignored because docker-compose does not support that for now
67+
func _TestConfigFile(t *testing.T) {
68+
h := TestHelper{T: t, testDir: "simple_configfile"}
69+
h.testUpDown(func(t *testing.T) {
70+
actual := getHttpBody(t, volumeUrl+"test_config.txt")
71+
assert.Assert(t, actual == "{\"response\":\"MYCONFIG\"}\n")
72+
})
73+
}

tests/simple_configfile/compose.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "3.7"
2+
services:
3+
entry:
4+
image: test-server
5+
ports:
6+
- 8080:8080
7+
configs:
8+
- source: test_config
9+
target: /volumes/test_config.txt
10+
11+
configs:
12+
test_config:
13+
file: ./test_config.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MYCONFIG

tests/simple_lifecycle/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ version: '3.7'
22

33
services:
44
test1:
5-
image: nginx
5+
image: test-server

tests/simple_secretfile/compose.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "3.7"
2+
services:
3+
entry:
4+
image: test-server
5+
ports:
6+
- 8080:8080
7+
secrets:
8+
- source: test_secret
9+
target: /volumes/test_secret.txt
10+
11+
secrets:
12+
test_secret:
13+
file: ./test_secret.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MYSECRET

tests/simple_volume/compose.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: "3.7"
2+
services:
3+
entry:
4+
image: test-server
5+
ports:
6+
- 8080:8080
7+
volumes:
8+
- ./test_volume.txt:/volumes/test_volume.txt

tests/simple_volume/test_volume.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MYVOLUME

0 commit comments

Comments
 (0)