From 4d14ef6eef370bf8d8533a19cb9930af2d396c3b Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Wed, 27 Nov 2024 12:35:33 +0700 Subject: [PATCH] fixup! CurrencyManager: Set AssetEnabled when StorePairs(enabled) --- currency/manager_test.go | 44 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/currency/manager_test.go b/currency/manager_test.go index b3eb6aabf86..536cb1783e3 100644 --- a/currency/manager_test.go +++ b/currency/manager_test.go @@ -462,25 +462,21 @@ func TestEnablePair(t *testing.T) { } } -func TestIsAssetEnabled_SetAssetEnabled(t *testing.T) { +func TestAssetEnabled(t *testing.T) { t.Parallel() p := initTest(t) err := p.IsAssetEnabled(asset.Empty) - if !errors.Is(err, asset.ErrNotSupported) { - t.Fatalf("received: '%v' but expected: '%v'", err, asset.ErrNotSupported) - } + assert.ErrorIs(t, err, asset.ErrNotSupported) + p.Pairs = nil + // Test enabling a pair when the pair manager is not initialised err = p.IsAssetEnabled(asset.Spot) - if err == nil { - t.Error("unexpected result") - } + assert.ErrorIs(t, err, ErrPairManagerNotInitialised) err = p.SetAssetEnabled(asset.Spot, true) - if err == nil { - t.Fatal("unexpected result") - } + assert.ErrorIs(t, err, ErrPairManagerNotInitialised) // Test asset type which doesn't exist p = initTest(t) @@ -488,39 +484,25 @@ func TestIsAssetEnabled_SetAssetEnabled(t *testing.T) { p.Pairs[asset.Spot].AssetEnabled = false err = p.IsAssetEnabled(asset.Spot) - if err == nil { - t.Error("unexpected result") - } + assert.ErrorIs(t, err, asset.ErrNotEnabled) err = p.SetAssetEnabled(asset.Spot, false) - if err != nil { - t.Fatal(err) - } + assert.NoError(t, err) err = p.SetAssetEnabled(asset.Spot, false) - if err == nil { - t.Fatal("unexpected result") - } + assert.NoError(t, err, "Setting to disabled twice should not error") err = p.IsAssetEnabled(asset.Spot) - if err == nil { - t.Error("unexpected result") - } + assert.ErrorIs(t, err, asset.ErrNotEnabled) err = p.SetAssetEnabled(asset.Spot, true) - if err != nil { - t.Fatal(err) - } + assert.NoError(t, err) err = p.SetAssetEnabled(asset.Spot, true) - if err == nil { - t.Fatal("unexpected result") - } + assert.NoError(t, err, "Setting to enabled twice should not error") err = p.IsAssetEnabled(asset.Spot) - if err != nil { - t.Error("unexpected result") - } + assert.NoError(t, err, "IsAssetEnabled should not error") } // TestFullStoreUnmarshalMarshal tests json Mashal and Unmarshal