(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestGetRegistryEndpoint(t *testing.T) { |
| 73 | testCases := []getRegistryEndpointTestCase{ |
| 74 | { |
| 75 | name: "Use auth server", |
| 76 | expectedIsDefault: true, |
| 77 | expectedEndpoint: "IndexServerAddress", |
| 78 | }, |
| 79 | { |
| 80 | name: "Use custom server", |
| 81 | registryURL: "custom", |
| 82 | expectedIsDefault: false, |
| 83 | expectedEndpoint: "custom", |
| 84 | }, |
| 85 | } |
| 86 | |
| 87 | for _, testCase := range testCases { |
| 88 | client := &client{ |
| 89 | APIClient: &fakeDockerClient{}, |
| 90 | } |
| 91 | |
| 92 | isDefault, endpoint, err := client.GetRegistryEndpoint(context.Background(), testCase.registryURL) |
| 93 | |
| 94 | if !testCase.expectedErr { |
| 95 | assert.NilError(t, err, "Unexpected error in testCase %s", testCase.name) |
| 96 | } else if err == nil { |
| 97 | t.Fatalf("Unexpected error %v in testCase %s", err, testCase.name) |
| 98 | } |
| 99 | |
| 100 | assert.Equal(t, isDefault, testCase.expectedIsDefault, "Unexpected isDefault bool in testCase %s", testCase.name) |
| 101 | assert.Equal(t, endpoint, testCase.expectedEndpoint, "Unexpected endpoint in testCase %s", testCase.name) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | type getAuthConfigTestCase struct { |
| 106 | name string |
nothing calls this directly
no test coverage detected