From 8dc1f924ced5a8b7e7f32c9b6bee07abe96c675b Mon Sep 17 00:00:00 2001 From: Kyle Morton Date: Tue, 26 Jul 2022 09:03:26 -0500 Subject: [PATCH] fix: Updated unit-test Signed-off-by: Kyle Morton --- internal/security/proxy/service_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/security/proxy/service_test.go b/internal/security/proxy/service_test.go index 219343a088..8ba4be59cd 100644 --- a/internal/security/proxy/service_test.go +++ b/internal/security/proxy/service_test.go @@ -90,17 +90,11 @@ func TestPostCertExists(t *testing.T) { func TestPostCertHttpError(t *testing.T) { fileName := "./testdata/configuration.toml" contents, err := os.ReadFile(fileName) - if err != nil { - t.Errorf("could not load configuration file (%s): %s", fileName, err.Error()) - return - } + require.NoError(t, err) configuration := &config.ConfigurationStruct{} err = toml.Unmarshal(contents, configuration) - if err != nil { - t.Errorf("unable to parse configuration file (%s): %s", fileName, err.Error()) - return - } + require.NoError(t, err) ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) defer ts.Close() @@ -115,6 +109,7 @@ func TestPostCertHttpError(t *testing.T) { service := NewService(NewRequestor(true, 10, "", mockLogger), mockLogger, configuration) mockCertPair := bootstrapConfig.CertKeyPair{Cert: "test-certificate", Key: "test-private-key"} e := service.postCert(mockCertPair) + require.Error(t, e) if e.reason != CertExisting { assert.Contains(t, e.Error(), "/admin/certificates") }