From 9e295cffa5d71a27eea14d5dbc0df2761c8785f9 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Tue, 19 Sep 2023 11:27:15 +0700 Subject: [PATCH] Tests: Improve test readability and clarity --- exchanges/sharedtestvalues/sharedtestvalues.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exchanges/sharedtestvalues/sharedtestvalues.go b/exchanges/sharedtestvalues/sharedtestvalues.go index c398f9314e7..8d0cce6134e 100644 --- a/exchanges/sharedtestvalues/sharedtestvalues.go +++ b/exchanges/sharedtestvalues/sharedtestvalues.go @@ -157,7 +157,8 @@ func TestFixtureToDataHandler(t *testing.T, seed, e exchange.IBotExchange, fixtu b := e.GetBase() seedBase := seed.GetBase() - assert.NoError(t, b.CurrencyPairs.Load(&seedBase.CurrencyPairs), "Loading currency pairs should not error") + err := b.CurrencyPairs.Load(&seedBase.CurrencyPairs) + assert.NoError(t, err, "Loading currency pairs should not error") b.Name = "fixture" b.Websocket = &stream.Websocket{ @@ -167,11 +168,10 @@ func TestFixtureToDataHandler(t *testing.T, seed, e exchange.IBotExchange, fixtu b.API.Endpoints = b.NewEndpoints() fixture, err := os.Open(fixturePath) - if err != nil { - t.Errorf("Error opening test fixture '%v': %v", fixturePath, err) - return - } - defer func() { assert.Nil(t, fixture.Close()) }() + assert.NoError(t, err, "Opening fixture '%s' should not error", fixturePath) + defer func() { + assert.NoError(t, fixture.Close(), "Closing the fixture file should not error") + }() s := bufio.NewScanner(fixture) for s.Scan() { @@ -180,5 +180,5 @@ func TestFixtureToDataHandler(t *testing.T, seed, e exchange.IBotExchange, fixtu t.Errorf("%v from message: %s", err, msg) } } - assert.Nil(t, s.Err()) + assert.NoError(t, s.Err(), "Fixture Scanner should not error") }