MCPcopy Create free account
hub / github.com/clouditor/clouditor / NewInMemoryStorage

Function NewInMemoryStorage

internal/testutil/storage.go:12–25  ·  view source on GitHub ↗

NewInMemoryStorage uses the inmemory package to create a new in-memory storage that can be used for unit testing. The funcs varargs can be used to immediately execute storage operations on it.

(t *testing.T, funcs ...func(s persistence.Storage))

Source from the content-addressed store, hash-verified

10// NewInMemoryStorage uses the inmemory package to create a new in-memory storage that can be used
11// for unit testing. The funcs varargs can be used to immediately execute storage operations on it.
12func NewInMemoryStorage(t *testing.T, funcs ...func(s persistence.Storage)) (s persistence.Storage) {
13 var err error
14
15 s, err = inmemory.NewStorage()
16 if err != nil {
17 t.Fatalf("Could not initialize in-memory db: %v", err)
18 }
19
20 for _, f := range funcs {
21 f(s)
22 }
23
24 return
25}
26
27// StorageWithError can be used to introduce various errors in a storage operation during unit testing.
28type StorageWithError struct {

Callers 15

TestPaginateStorageFunction · 0.92
TestNewServiceFunction · 0.92
TestService_GetEvidenceFunction · 0.92
TestNewServiceFunction · 0.92

Calls 1

NewStorageFunction · 0.92

Tested by 15

TestPaginateStorageFunction · 0.74
TestNewServiceFunction · 0.74
TestService_GetEvidenceFunction · 0.74
TestNewServiceFunction · 0.74