public async Task TestNewRegistryErrorException_jsonErrorOutputAsync() { using (HttpResponseMessage response = new HttpResponseMessage { Content = new StringContent( "{\"errors\": [{\"code\": \"MANIFEST_UNKNOWN\", \"message\": \"manifest unknown\"}]}") }) { HttpResponseException httpException = new HttpResponseException(response); RegistryErrorException registryException = await secureEndpointCaller.NewRegistryErrorExceptionAsync(httpException).ConfigureAwait(false); Assert.AreSame(httpException.Cause, registryException.Cause); Assert.AreEqual( "Tried to actionDescription but failed because: manifest unknown | If this is a bug, " + "please file an issue at https://github.com/GoogleContainerTools/fib/issues/new", registryException.Message); } }
public async Task TestNewRegistryErrorException_nonJsonErrorOutputAsync() { using (HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(">>>>> (404) page not found <<<<<") }) { HttpResponseException httpException = new HttpResponseException(message); RegistryErrorException registryException = await secureEndpointCaller.NewRegistryErrorExceptionAsync(httpException).ConfigureAwait(false); Assert.AreSame(httpException.Cause, registryException.Cause); Assert.AreEqual( "Tried to actionDescription but failed because: registry returned error code 404; " + "possible causes include invalid or wrong reference. Actual error output follows:\n" + ">>>>> (404) page not found <<<<<\n" + " | If this is a bug, please file an issue at " + "https://github.com/GoogleContainerTools/fib/issues/new", registryException.Message); } }