forked from bf2fc6cc711aee1a0c2a/kas-fleet-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bf2fc6cc711aee1a0c2a#1705 from MikeEdgar/in-memory…
…-storage fix: create or update in-memory storage for both Lock and Store ops
- Loading branch information
Showing
4 changed files
with
70 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
internal/kafka/internal/services/kafkatlscertmgmt/memory_storage_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package kafkatlscertmgmt | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/pkg/db" | ||
"github.com/onsi/gomega" | ||
) | ||
|
||
func Test_memoryStorage_Load(t *testing.T) { | ||
type args struct { | ||
key string | ||
value []byte | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "successfully loads the same value stored", | ||
args: args{ | ||
key: "some-key", | ||
value: []byte("some byte"), | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
testcase := tt | ||
t.Run(testcase.name, func(t *testing.T) { | ||
t.Parallel() | ||
g := gomega.NewWithT(t) | ||
storage := newInMemoryStorage(db.NewMockConnectionFactory(nil)) | ||
|
||
storeErr := storage.Store(context.Background(), testcase.args.key, testcase.args.value) | ||
g.Expect(storeErr != nil).To(gomega.Equal(testcase.wantErr)) | ||
|
||
outputValue, loadErr := storage.Load(context.Background(), testcase.args.key) | ||
g.Expect(loadErr == nil) | ||
g.Expect(outputValue).To(gomega.Equal(testcase.args.value)) | ||
}) | ||
} | ||
} |