mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-27 00:19:36 -05:00
436ade2dc9
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
38 lines
817 B
Go
38 lines
817 B
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMemMapStorage(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
storage := NewMemMapStorage()
|
|
|
|
testDEK1 := []byte("test DEK")
|
|
testDEK2 := []byte("more test DEK")
|
|
ctx := context.Background()
|
|
|
|
// request unset value
|
|
_, err := storage.Get(ctx, "test:input")
|
|
assert.ErrorIs(err, ErrDEKUnset)
|
|
|
|
// test Put method
|
|
assert.NoError(storage.Put(ctx, "volume01", testDEK1))
|
|
assert.NoError(storage.Put(ctx, "volume02", testDEK2))
|
|
|
|
// make sure values have been set
|
|
val, err := storage.Get(ctx, "volume01")
|
|
assert.NoError(err)
|
|
assert.Equal(testDEK1, val)
|
|
val, err = storage.Get(ctx, "volume02")
|
|
assert.NoError(err)
|
|
assert.Equal(testDEK2, val)
|
|
|
|
_, err = storage.Get(ctx, "invalid:key")
|
|
assert.ErrorIs(err, ErrDEKUnset)
|
|
}
|