Skip to content

Commit

Permalink
Added a test case for all 3 providers failing
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Sep 21, 2020
1 parent e7eec41 commit 71d0a4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions conversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ func TestClient_GetConversionFailedWhatsOnChain(t *testing.T) {
t.Logf("found satoshis: %d from provider: %s", satoshis, provider.Names())
}

// TestClient_GetConversionFailedAll will test the method GetConversion()
func TestClient_GetConversionFailedAll(t *testing.T) {
t.Parallel()

// Set a valid client (1 valid, 2 invalid)
client := newMockClient(&mockWOCFailed{}, &mockPaprikaFailed{}, &mockPreevFailed{}, ProviderPreev&ProviderWhatsOnChain&ProviderCoinPaprika)

// Test a NON accepted currency
_, _, rateErr := client.GetConversion(123, 1)
if rateErr == nil {
t.Fatalf("expected an error to occur, currency %d is not accepted", 123)
}

// Test a valid response (after failing on the first provider)
satoshis, _, err := client.GetConversion(CurrencyDollars, 1)
if err == nil {
t.Fatalf("error was expected but got nil")
} else if satoshis != 0 {
t.Fatalf("satoshis should be zero but was %d", satoshis)
}
}

// TestClient_GetConversionCustomProviders will test the method GetConversion()
func TestClient_GetConversionCustomProviders(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion rates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func TestClient_GetRateFailedAll(t *testing.T) {
if err == nil {
t.Fatalf("error expected but got nil")
} else if rate != 0 {
t.Fatalf("rate should be zero")
t.Fatalf("rate should be zero but was: %f", rate)
}
}

Expand Down

0 comments on commit 71d0a4b

Please sign in to comment.