From 9bb994587cab0a1271df82f2aa75ff69b73a87ae Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Tue, 17 Sep 2024 14:49:47 +0100 Subject: [PATCH] Add config test factories Signed-off-by: Enrique Lacal --- internal/blockchain/bifactory/factory_test.go | 24 ++++++++++++++++++- internal/database/difactory/factory_test.go | 8 +++++++ .../dataexchange/dxfactory/factory_test.go | 8 +++++++ internal/events/eifactory/factory_test.go | 23 +++++++++++++++++- internal/identity/iifactory/factory_test.go | 8 +++++++ internal/tokens/tifactory/factory_test.go | 8 +++++++ 6 files changed, 77 insertions(+), 2 deletions(-) diff --git a/internal/blockchain/bifactory/factory_test.go b/internal/blockchain/bifactory/factory_test.go index 927e36d50..a2b493c79 100644 --- a/internal/blockchain/bifactory/factory_test.go +++ b/internal/blockchain/bifactory/factory_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/stretchr/testify/assert" ) @@ -30,9 +31,30 @@ func TestGetPluginUnknown(t *testing.T) { assert.Regexp(t, "FF10110", err) } -func TestGetPlugin(t *testing.T) { +func TestGetPluginEthereum(t *testing.T) { ctx := context.Background() plugin, err := GetPlugin(ctx, "ethereum") assert.NoError(t, err) assert.NotNil(t, plugin) } + +func TestGetPluginFabric(t *testing.T) { + ctx := context.Background() + plugin, err := GetPlugin(ctx, "fabric") + assert.NoError(t, err) + assert.NotNil(t, plugin) +} + +func TestGetPluginTezos(t *testing.T) { + ctx := context.Background() + plugin, err := GetPlugin(ctx, "tezos") + assert.NoError(t, err) + assert.NotNil(t, plugin) +} + +var root = config.RootSection("di") + +func TestInitConfig(t *testing.T) { + conf := root.SubArray("plugins") + InitConfig(conf) +} diff --git a/internal/database/difactory/factory_test.go b/internal/database/difactory/factory_test.go index 505414fde..116a35c05 100644 --- a/internal/database/difactory/factory_test.go +++ b/internal/database/difactory/factory_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/stretchr/testify/assert" ) @@ -36,3 +37,10 @@ func TestGetPlugin(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, plugin) } + +var root = config.RootSection("di") + +func TestInitConfig(t *testing.T) { + conf := root.SubArray("plugins") + InitConfig(conf) +} diff --git a/internal/dataexchange/dxfactory/factory_test.go b/internal/dataexchange/dxfactory/factory_test.go index 7fca265d2..989570a10 100644 --- a/internal/dataexchange/dxfactory/factory_test.go +++ b/internal/dataexchange/dxfactory/factory_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/stretchr/testify/assert" ) @@ -36,3 +37,10 @@ func TestGetPlugin(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, plugin) } + +var root = config.RootSection("di") + +func TestInitConfig(t *testing.T) { + conf := root.SubArray("plugins") + InitConfig(conf) +} diff --git a/internal/events/eifactory/factory_test.go b/internal/events/eifactory/factory_test.go index fb5b7d219..fb964793e 100644 --- a/internal/events/eifactory/factory_test.go +++ b/internal/events/eifactory/factory_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/stretchr/testify/assert" ) @@ -30,9 +31,29 @@ func TestGetPluginUnknown(t *testing.T) { assert.Regexp(t, "FF10172", err) } -func TestGetPlugin(t *testing.T) { +func TestGetPluginWebSockets(t *testing.T) { ctx := context.Background() plugin, err := GetPlugin(ctx, "websockets") assert.NoError(t, err) assert.NotNil(t, plugin) } + +func TestGetPluginWebHooks(t *testing.T) { + ctx := context.Background() + plugin, err := GetPlugin(ctx, "webhooks") + assert.NoError(t, err) + assert.NotNil(t, plugin) +} + +func TestGetPluginEvents(t *testing.T) { + ctx := context.Background() + plugin, err := GetPlugin(ctx, "system") + assert.NoError(t, err) + assert.NotNil(t, plugin) +} + +var root = config.RootSection("di") + +func TestInitConfig(t *testing.T) { + InitConfig(root) +} diff --git a/internal/identity/iifactory/factory_test.go b/internal/identity/iifactory/factory_test.go index 4f2cac10b..3110dbb65 100644 --- a/internal/identity/iifactory/factory_test.go +++ b/internal/identity/iifactory/factory_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/stretchr/testify/assert" ) @@ -36,3 +37,10 @@ func TestGetPlugin(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, plugin) } + +var root = config.RootSection("di") + +func TestInitConfig(t *testing.T) { + conf := root.SubArray("plugins") + InitConfig(conf) +} diff --git a/internal/tokens/tifactory/factory_test.go b/internal/tokens/tifactory/factory_test.go index 96085907e..f1d122932 100644 --- a/internal/tokens/tifactory/factory_test.go +++ b/internal/tokens/tifactory/factory_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/stretchr/testify/assert" ) @@ -36,3 +37,10 @@ func TestGetPlugin(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, plugin) } + +var root = config.RootSection("tokens") + +func TestInitConfig(t *testing.T) { + conf := root.SubArray("plugins") + InitConfig(conf) +}