From a871cd7b603881309fdd9f35a5d565a7104ad98f Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Fri, 4 Oct 2024 10:58:09 +0200 Subject: [PATCH] Fix tests --- hydrate.go | 5 +---- hydrate_test.go | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hydrate.go b/hydrate.go index e81ee88..2209c6a 100644 --- a/hydrate.go +++ b/hydrate.go @@ -7,7 +7,6 @@ import ( "github.com/0xsequence/go-cloudsecrets/gcp" "github.com/0xsequence/go-cloudsecrets/nosecrets" - "github.com/davecgh/go-spew/spew" "golang.org/x/sync/errgroup" ) @@ -55,12 +54,10 @@ func hydrateConfig(ctx context.Context, provider secretsProvider, v reflect.Valu } ga := &collector{} - ga.collectSecretFields(v, "") + ga.collectSecretFields(v, "config") fields := ga.fields - spew.Dump(fields) - g := &errgroup.Group{} for _, field := range fields { field := field diff --git a/hydrate_test.go b/hydrate_test.go index 5c7cdcb..e58cfb9 100644 --- a/hydrate_test.go +++ b/hydrate_test.go @@ -31,13 +31,7 @@ type analytics struct { func TestFailWhenPassedValueIsNotStruct(t *testing.T) { input := "hello" - v := reflect.ValueOf(input) - provider := mock.NewSecretsProvider(map[string]string{ - "dbPassword": "changethissecret", - "analyticsPassword": "AuthTokenSecret", - }) - - assert.Error(t, hydrateStruct(context.Background(), provider, v)) + assert.Error(t, Hydrate(context.Background(), "", input)) } func TestReplacePlaceholdersWithSecrets(t *testing.T) { @@ -117,7 +111,7 @@ func TestReplacePlaceholdersWithSecrets(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { v := reflect.ValueOf(tt.conf) - err := hydrateStruct(ctx, mock.NewSecretsProvider(tt.storage), v) + err := hydrateConfig(ctx, mock.NewSecretsProvider(tt.storage), v) if err != nil { if tt.wantErr { assert.Equal(t, tt.wantConf, tt.conf)