Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Moving test cases comments to dedicated field #881

Merged
merged 1 commit into from
Apr 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions exchange/bidder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -254,8 +253,8 @@ func TestMultiCurrencies(t *testing.T) {
rates currencies.Rates
expectedBids []bid
expectedBadCurrencyErrors []error
description string
}{
// Bidder respond with the same currency (default one) on all HTTP responses
{
bids: []bid{
{currency: "USD", price: 1.1},
Expand All @@ -279,8 +278,8 @@ func TestMultiCurrencies(t *testing.T) {
{currency: "USD", price: 1.3},
},
expectedBadCurrencyErrors: []error{},
description: "Case 1 - Bidder respond with the same currency (default one) on all HTTP responses",
},
// Bidder respond with no currency on all HTTP responses
{
bids: []bid{
{currency: "", price: 1.1},
Expand All @@ -304,8 +303,8 @@ func TestMultiCurrencies(t *testing.T) {
{currency: "USD", price: 1.3},
},
expectedBadCurrencyErrors: []error{},
description: "Case 2 - Bidder respond with no currency on all HTTP responses",
},
// Bidder respond with the same non default currency on all HTTP responses
{
bids: []bid{
{currency: "EUR", price: 1.1},
Expand All @@ -329,8 +328,8 @@ func TestMultiCurrencies(t *testing.T) {
{currency: "USD", price: 1.3 * 1.1435678764},
},
expectedBadCurrencyErrors: []error{},
description: "Case 3 - Bidder respond with the same non default currency on all HTTP responses",
},
// Bidder respond with a mix of currencies on all HTTP responses
{
bids: []bid{
{currency: "USD", price: 1.1},
Expand All @@ -354,8 +353,8 @@ func TestMultiCurrencies(t *testing.T) {
{currency: "USD", price: 1.3 * 1.3050530256},
},
expectedBadCurrencyErrors: []error{},
description: "Case 4 - Bidder respond with a mix of currencies on all HTTP responses",
},
// Bidder respond with a mix of currencies and no currency on all HTTP responses
{
bids: []bid{
{currency: "", price: 1.1},
Expand All @@ -379,8 +378,8 @@ func TestMultiCurrencies(t *testing.T) {
{currency: "USD", price: 1.3 * 1.3050530256},
},
expectedBadCurrencyErrors: []error{},
description: "Case 5 - Bidder respond with a mix of currencies and no currency on all HTTP responses",
},
// Bidder respond with a mix of currencies and one unknown on all HTTP responses
{
bids: []bid{
{currency: "JPY", price: 1.1},
Expand All @@ -405,8 +404,8 @@ func TestMultiCurrencies(t *testing.T) {
expectedBadCurrencyErrors: []error{
errors.New("Currency conversion rate not found: 'JPY' => 'USD'"),
},
description: "Case 6 - Bidder respond with a mix of currencies and one unknown on all HTTP responses",
},
// Bidder respond with currencies not having any rate on all HTTP responses
{
bids: []bid{
{currency: "JPY", price: 1.1},
Expand All @@ -430,8 +429,8 @@ func TestMultiCurrencies(t *testing.T) {
errors.New("Currency conversion rate not found: 'BZD' => 'USD'"),
errors.New("Currency conversion rate not found: 'DKK' => 'USD'"),
},
description: "Case 7 - Bidder respond with currencies not having any rate on all HTTP responses",
},
// Bidder respond with not existing currencies
{
bids: []bid{
{currency: "AAA", price: 1.1},
Expand All @@ -455,6 +454,7 @@ func TestMultiCurrencies(t *testing.T) {
errors.New("currency: tag is not a recognized currency"),
errors.New("currency: tag is not a recognized currency"),
},
description: "Case 8 - Bidder respond with not existing currencies",
},
}

Expand Down Expand Up @@ -525,8 +525,8 @@ func TestMultiCurrencies(t *testing.T) {
currency: seatBid.currency,
}
}
assert.ElementsMatch(t, tc.expectedBids, resultLightBids, fmt.Sprintf("Case: %v", tc.bids))
assert.ElementsMatch(t, tc.expectedBadCurrencyErrors, errs, fmt.Sprintf("Case: %v", tc.bids))
assert.ElementsMatch(t, tc.expectedBids, resultLightBids, tc.description)
assert.ElementsMatch(t, tc.expectedBadCurrencyErrors, errs, tc.description)
}
}

Expand All @@ -541,14 +541,14 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) {
bidCurrency []string
expectedBidsCount uint
expectedBadCurrencyErrors []error
description string
}{
// Bidder respond with the same currency (default one) on all HTTP responses
{
bidCurrency: []string{"USD", "USD", "USD"},
expectedBidsCount: 3,
expectedBadCurrencyErrors: []error{},
description: "Case 1 - Bidder respond with the same currency (default one) on all HTTP responses",
},
// Bidder respond with the same currency (not default one) on all HTTP responses
{
bidCurrency: []string{"EUR", "EUR", "EUR"},
expectedBidsCount: 0,
Expand All @@ -557,54 +557,55 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) {
fmt.Errorf("Constant rates doesn't proceed to any conversions, cannot convert 'EUR' => 'USD'"),
fmt.Errorf("Constant rates doesn't proceed to any conversions, cannot convert 'EUR' => 'USD'"),
},
description: "Case 2 - Bidder respond with the same currency (not default one) on all HTTP responses",
},
// Bidder responds with currency not set on all HTTP responses
{
bidCurrency: []string{"", "", ""},
expectedBidsCount: 3,
expectedBadCurrencyErrors: []error{},
description: "Case 3 - Bidder responds with currency not set on all HTTP responses",
},
// Bidder responds with a mix of not set and default currency in HTTP responses
{
bidCurrency: []string{"", "USD", ""},
expectedBidsCount: 3,
expectedBadCurrencyErrors: []error{},
description: "Case 4 - Bidder responds with a mix of not set and default currency in HTTP responses",
},
// Bidder responds with a mix of not set and default currency in HTTP responses
{
bidCurrency: []string{"USD", "USD", ""},
expectedBidsCount: 3,
expectedBadCurrencyErrors: []error{},
description: "Case 5 - Bidder responds with a mix of not set and default currency in HTTP responses",
},
// Bidder responds with a mix of not set and default currency in HTTP responses
{
bidCurrency: []string{"", "", "USD"},
expectedBidsCount: 3,
expectedBadCurrencyErrors: []error{},
description: "Case 6 - Bidder responds with a mix of not set and default currency in HTTP responses",
},
// Bidder responds with a mix of not set, non default currency and default currency in HTTP responses
{
bidCurrency: []string{"EUR", "", "USD"},
expectedBidsCount: 2,
expectedBadCurrencyErrors: []error{
fmt.Errorf("Constant rates doesn't proceed to any conversions, cannot convert 'EUR' => 'USD'"),
},
description: "Case 7 - Bidder responds with a mix of not set, non default currency and default currency in HTTP responses",
},
// Bidder responds with a mix of not set, non default currency and default currency in HTTP responses
{
bidCurrency: []string{"GBP", "", "USD"},
expectedBidsCount: 2,
expectedBadCurrencyErrors: []error{
fmt.Errorf("Constant rates doesn't proceed to any conversions, cannot convert 'GBP' => 'USD'"),
},
description: "Case 8 - Bidder responds with a mix of not set, non default currency and default currency in HTTP responses",
},
// Bidder responds with a mix of not set and empty currencies (default currency) in HTTP responses
{
bidCurrency: []string{"GBP", "", ""},
expectedBidsCount: 2,
expectedBadCurrencyErrors: []error{
fmt.Errorf("Constant rates doesn't proceed to any conversions, cannot convert 'GBP' => 'USD'"),
},
description: "Case 9 - Bidder responds with a mix of not set and empty currencies (default currency) in HTTP responses",
},
// Bidder respond with not existing currencies
{
Expand All @@ -615,6 +616,7 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) {
errors.New("currency: tag is not a recognized currency"),
errors.New("currency: tag is not a recognized currency"),
},
description: "Case 10 - Bidder respond with not existing currencies",
},
}

Expand Down Expand Up @@ -660,9 +662,9 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) {
)

// Verify:
assert.Equal(t, false, (seatBid == nil && tc.expectedBidsCount != 0), fmt.Sprint("Case:", strings.Join(tc.bidCurrency, ",")))
assert.Equal(t, tc.expectedBidsCount, uint(len(seatBid.bids)), fmt.Sprint("Case:", strings.Join(tc.bidCurrency, ",")))
assert.ElementsMatch(t, tc.expectedBadCurrencyErrors, errs, fmt.Sprint("Case:", strings.Join(tc.bidCurrency, ",")))
assert.Equal(t, false, (seatBid == nil && tc.expectedBidsCount != 0), tc.description)
assert.Equal(t, tc.expectedBidsCount, uint(len(seatBid.bids)), tc.description)
assert.ElementsMatch(t, tc.expectedBadCurrencyErrors, errs, tc.description)
}
}

Expand Down