| 1 | package runnercfg |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "os" |
| 6 | "path/filepath" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | func TestPingDockerUnreachable(t *testing.T) { |
| 11 | dir := t.TempDir() |
| 12 | bin := filepath.Join(dir, "docker") |
| 13 | if err := os.WriteFile(bin, []byte("#!/bin/sh\necho boom >&2\nexit 1\n"), 0o755); err != nil { |
| 14 | t.Fatal(err) |
| 15 | } |
| 16 | st := PingDocker(context.Background(), bin) |
| 17 | if st.Reachable || st.Error == "" { |
| 18 | t.Fatalf("%+v", st) |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | func TestPingDockerMissingBinary(t *testing.T) { |
| 23 | st := PingDocker(context.Background(), filepath.Join(t.TempDir(), "nope")) |
| 24 | if st.Reachable || st.Error == "" { |
| 25 | t.Fatalf("%+v", st) |
| 26 | } |
| 27 | } |