(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestDetect(t *testing.T) { |
| 26 | type testCase struct { |
| 27 | names []string |
| 28 | expected Type |
| 29 | err string |
| 30 | } |
| 31 | testCases := []testCase{ |
| 32 | { |
| 33 | names: nil, |
| 34 | expected: CNI, |
| 35 | }, |
| 36 | { |
| 37 | names: []string{"none"}, |
| 38 | expected: None, |
| 39 | }, |
| 40 | { |
| 41 | names: []string{"host"}, |
| 42 | expected: Host, |
| 43 | }, |
| 44 | { |
| 45 | names: []string{"bridge"}, |
| 46 | expected: CNI, |
| 47 | }, |
| 48 | { |
| 49 | names: []string{"foo", "bar"}, |
| 50 | expected: CNI, |
| 51 | }, |
| 52 | { |
| 53 | names: []string{"foo", "bar", "bridge"}, |
| 54 | expected: CNI, |
| 55 | }, |
| 56 | { |
| 57 | names: []string{"none", "host"}, |
| 58 | err: "mixed network types", |
| 59 | }, |
| 60 | { |
| 61 | names: []string{"none", "bridge"}, |
| 62 | err: "mixed network types", |
| 63 | }, |
| 64 | { |
| 65 | names: []string{"host", "foo"}, |
| 66 | err: "mixed network types", |
| 67 | }, |
| 68 | } |
| 69 | |
| 70 | for _, tc := range testCases { |
| 71 | got, err := Detect(tc.names) |
| 72 | if tc.err == "" { |
| 73 | assert.NilError(t, err) |
| 74 | assert.Equal(t, tc.expected, got) |
| 75 | } else { |
| 76 | assert.ErrorContains(t, err, tc.err) |
| 77 | } |
| 78 | } |
| 79 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…