Skip to content
Snippets Groups Projects
Commit 15ae8de7 authored by Jonas Kjærandsen's avatar Jonas Kjærandsen
Browse files

Replaced status codes with constants in the main test, also changed the error messages.

parent 2e4ae360
No related branches found
No related tags found
1 merge request!2Merge react-branch into main.
...@@ -38,7 +38,7 @@ func TestUrlIntelligenceOK(t *testing.T) { ...@@ -38,7 +38,7 @@ func TestUrlIntelligenceOK(t *testing.T) {
} }
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 200 { if res.StatusCode != http.StatusOK {
t.Fatalf("Test failed, error code different from expected 200, received: %d", res.StatusCode) t.Fatalf("Test failed, error code different from expected 200, received: %d", res.StatusCode)
} }
} }
...@@ -66,12 +66,11 @@ func TestUrlIntelligenceUnauthorized(t *testing.T) { ...@@ -66,12 +66,11 @@ func TestUrlIntelligenceUnauthorized(t *testing.T) {
} }
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 401 { if res.StatusCode != http.StatusUnauthorized {
t.Fatalf("Test failed, error code different from expected 401, received: %d", res.StatusCode) t.Fatalf("Test failed, error code different from expected 401, received: %d", res.StatusCode)
} }
} }
/** /**
* API - Test to check if the hash intelligence endpoint returns HTTP StatusOK when expected * API - Test to check if the hash intelligence endpoint returns HTTP StatusOK when expected
*/ */
...@@ -99,8 +98,8 @@ func TestHashIntelligenceOK(t *testing.T){ ...@@ -99,8 +98,8 @@ func TestHashIntelligenceOK(t *testing.T){
} }
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 200 { if res.StatusCode != http.StatusOK {
t.Fatalf("Test failed, error code different from expected 200, received: %d", res.StatusCode) t.Fatalf("Test failed, status code different from expected 200, received: %d", res.StatusCode)
} }
} }
...@@ -125,8 +124,8 @@ func TestHashIntelligenceUnauthorized(t *testing.T){ ...@@ -125,8 +124,8 @@ func TestHashIntelligenceUnauthorized(t *testing.T){
} }
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 401 { if res.StatusCode != http.StatusUnauthorized {
t.Fatalf("Test failed, error code different from expected 401, received: %d", res.StatusCode) t.Fatalf("Test failed, status code different from expected 401, received: %d", res.StatusCode)
} }
} }
...@@ -166,11 +165,10 @@ func TestUrlIntelligenceValidOutput(t *testing.T) { ...@@ -166,11 +165,10 @@ func TestUrlIntelligenceValidOutput(t *testing.T) {
} }
defer res.Body.Close() defer res.Body.Close()
if res.StatusCode != 200 { if res.StatusCode != http.StatusOK {
t.Fatalf("Test failed, error code different from expected 200, received: %d", res.StatusCode) t.Fatalf("Test failed, status code different from expected 200, received: %d", res.StatusCode)
} }
body, err := ioutil.ReadAll(res.Body) body, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
t.Fatalf("Error: reading api response") t.Fatalf("Error: reading api response")
...@@ -251,7 +249,6 @@ func TestHash_IntelligenceValidOutput(t *testing.T) { ...@@ -251,7 +249,6 @@ func TestHash_IntelligenceValidOutput(t *testing.T) {
t.Fatalf("Test failed, error code different from expected 200, received: %d", res.StatusCode) t.Fatalf("Test failed, error code different from expected 200, received: %d", res.StatusCode)
} }
body, err := ioutil.ReadAll(res.Body) body, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
t.Fatalf("Error: reading api response") t.Fatalf("Error: reading api response")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment