(t *testing.T)
| 180 | } |
| 181 | |
| 182 | func TestSSHCacheResolveWithError(t *testing.T) { |
| 183 | ssh := newFakeResolver() |
| 184 | cache := withSSHCache(ssh).(*sshCache) |
| 185 | |
| 186 | assert.Equal(t, 0, len(cache.endpoints)) |
| 187 | |
| 188 | ssh.responses["userandhost"] = sshAuthResponse{Message: "resolve error", Href: "real"} |
| 189 | |
| 190 | e := Endpoint{ |
| 191 | SSHMetadata: sshp.SSHMetadata{ |
| 192 | UserAndHost: "userandhost", |
| 193 | Port: "1", |
| 194 | Path: "path", |
| 195 | }, |
| 196 | } |
| 197 | |
| 198 | res, err := cache.Resolve(e, "post") |
| 199 | assert.NotNil(t, err) |
| 200 | assert.Equal(t, "real", res.Href) |
| 201 | |
| 202 | assert.Equal(t, 0, len(cache.endpoints)) |
| 203 | delete(ssh.responses, "userandhost") |
| 204 | res2, err := cache.Resolve(e, "post") |
| 205 | assert.Nil(t, err) |
| 206 | assert.Equal(t, "", res2.Href) |
| 207 | } |
| 208 | |
| 209 | func newFakeResolver() *fakeResolver { |
| 210 | return &fakeResolver{responses: make(map[string]sshAuthResponse)} |
nothing calls this directly
no test coverage detected