Skip to content

Commit

Permalink
Added typofix to tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Knight <knight@linux.com>
  • Loading branch information
eddie-knight committed Aug 30, 2024
1 parent c443f45 commit ddac345
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ func setupMockContextCLA(t *testing.T) echo.Context {
}

func TestHandleRetrieveCLAText_MissingClaURL(t *testing.T) {
origClaUrl := os.Getenv(envClsUrl)
origClaUrl := os.Getenv(envClaUrl)
defer func() {
resetEnvVariable(t, envClsUrl, origClaUrl)
resetEnvVariable(t, envClaUrl, origClaUrl)
}()
resetEnvVariable(t, envClsUrl, "")
resetEnvVariable(t, envClaUrl, "")

err := handleRetrieveCLAText(setupMockContextCLA(t))

assert.EqualError(t, err, msgMissingClaUrl)
}

func TestHandleRetrieveCLAText_BadResponseCode(t *testing.T) {
origClaUrl := os.Getenv(envClsUrl)
origClaUrl := os.Getenv(envClaUrl)
defer func() {
resetEnvVariable(t, envClsUrl, origClaUrl)
resetEnvVariable(t, envClaUrl, origClaUrl)
}()

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -125,16 +125,16 @@ func TestHandleRetrieveCLAText_BadResponseCode(t *testing.T) {
}))
defer ts.Close()

assert.NoError(t, os.Setenv(envClsUrl, ts.URL+pathClaText))
assert.NoError(t, os.Setenv(envClaUrl, ts.URL+pathClaText))
assert.EqualError(t, handleRetrieveCLAText(setupMockContextCLA(t)), "unexpected cla text response code: 403")
}

func TestHandleRetrieveCLAText(t *testing.T) {
callCount := 0

origClaUrl := os.Getenv(envClsUrl)
origClaUrl := os.Getenv(envClaUrl)
defer func() {
resetEnvVariable(t, envClsUrl, origClaUrl)
resetEnvVariable(t, envClaUrl, origClaUrl)
}()

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -147,7 +147,7 @@ func TestHandleRetrieveCLAText(t *testing.T) {
}))
defer ts.Close()

assert.NoError(t, os.Setenv(envClsUrl, ts.URL+pathClaText))
assert.NoError(t, os.Setenv(envClaUrl, ts.URL+pathClaText))
assert.NoError(t, handleRetrieveCLAText(setupMockContextCLA(t)))
assert.Equal(t, callCount, 1)

Expand All @@ -160,9 +160,9 @@ func TestHandleRetrieveCLAText(t *testing.T) {
func TestHandleRetrieveCLATextWithBadURL(t *testing.T) {
callCount := 0

origClaUrl := os.Getenv(envClsUrl)
origClaUrl := os.Getenv(envClaUrl)
defer func() {
resetEnvVariable(t, envClsUrl, origClaUrl)
resetEnvVariable(t, envClaUrl, origClaUrl)
}()

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -175,7 +175,7 @@ func TestHandleRetrieveCLATextWithBadURL(t *testing.T) {
}))
defer ts.Close()

assert.NoError(t, os.Setenv(envClsUrl, "badURLProtocol"+ts.URL+pathClaText))
assert.NoError(t, os.Setenv(envClaUrl, "badURLProtocol"+ts.URL+pathClaText))
assert.Error(t, handleRetrieveCLAText(setupMockContextCLA(t)), `unsupported protocol scheme "badurlprotocolhttp"`)
assert.Equal(t, callCount, 0)
}
Expand Down

0 comments on commit ddac345

Please sign in to comment.