ci_network_test.go
⎇
Raw
1package e2e
2
3import "testing"
4
5// TestCINetwork checks that CI_NETWORK reaches the container create call.
6// An engine network is how a CI container gets IPv6 or an isolated segment.
7func TestCINetwork(t *testing.T) {
8 networkMode := func(m *mockDocker) any {
9 host, _ := m.createBody()["HostConfig"].(map[string]any)
10 return host["NetworkMode"]
11 }
12
13 t.Run("unset leaves the engine default", func(t *testing.T) {
14 e, m, admin := ciEnv(t)
15 m.queueExec(execResp{output: "hi\n"})
16 sha := ciSeedToml(e, ciSimpleTOML)
17 runID := ciTrigger(e, admin, sha, nil)
18 if got := ciWaitForRun(e, runID); got != "success" {
19 t.Fatalf("status = %q", got)
20 }
21 if got := networkMode(m); got != nil {
22 t.Errorf("NetworkMode = %v, want absent", got)
23 }
24 })
25
26 t.Run("set joins that network", func(t *testing.T) {
27 e, m, admin := ciEnv(t, "CI_NETWORK", "hearthforge-ci")
28 m.queueExec(execResp{output: "hi\n"})
29 sha := ciSeedToml(e, ciSimpleTOML)
30 runID := ciTrigger(e, admin, sha, nil)
31 if got := ciWaitForRun(e, runID); got != "success" {
32 t.Fatalf("status = %q", got)
33 }
34 if got := networkMode(m); got != "hearthforge-ci" {
35 t.Errorf("NetworkMode = %v", got)
36 }
37 })
38}
39