Skip to content

Commit

Permalink
ci: switch if checking in api_test to asserts
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 committed Jan 29, 2025
1 parent eb16d3d commit cf942c5
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,9 @@ func TestMetricsEndpoint(t *testing.T) {

// Test the /metrics endpoint
resp, err := http.Get(fmt.Sprintf("%s/metrics", metricsBaseURL))
if resp == nil {
t.Fatal("failed to get response from metrics endpoint")
}
if err != nil {
t.Fatalf("failed to call metrics endpoint: %v", err)
}
if resp.StatusCode != http.StatusOK {
t.Errorf("expected status 200, got %v", resp.StatusCode)
}
assert.NotEqual(t, resp, nil)
assert.NoError(t, err, "failed to call metrics endpoint")
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestMetricsRegistered(t *testing.T) {
Expand Down Expand Up @@ -337,22 +331,13 @@ func TestCreateWalletReturnsMnemonic(t *testing.T) {
defer cleanup()

resp, err := http.Get(fmt.Sprintf("%s/api/wallet/create", apiBaseURL))
if resp == nil {
t.Fatal("Failed calling /api/wallet/create")
}
if err != nil {
t.Fatalf("Failed to call /api/wallet/create: %v", err)
}
defer resp.Body.Close()
assert.NotEqual(t, resp, nil)
assert.NoError(t, err, "failed to call wallet create endpoint")
assert.Equal(t, http.StatusOK, resp.StatusCode)

body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("Failed to read create wallet response body: %v", err)
}

if resp.StatusCode != http.StatusOK {
t.Fatalf("Expected 200, got %d: %s", resp.StatusCode, string(body))
}
resp.Body.Close()
assert.NoError(t, err, "failed to read wallet create response")

var createWalletResponse map[string]interface{}
if err := json.Unmarshal(body, &createWalletResponse); err != nil {
Expand Down

0 comments on commit cf942c5

Please sign in to comment.