Files
kopia/tests/robustness/snapmeta/simple_test.go
Julio Lopez 08dd138802 refactor(general): cleanup a few tests (#4519)
Cleanup robustness tests and `local_fs_test.go`
"Mechanical" changes: 
- Use `require` helpers
- Use `testing.T` helpers
 
Note change in functionality: The use of `require` helpers
stops tests once a check fails. Before, various checks
were using `t.Error`, which fails the test but allows the
test to continue its execution.


* refactor(general): cleanup robustness/snapmeta/kopia_persister_light_test.go

Use `require` helpers
Use `testing.T` helpers

* refactor(general): cleanup local_fs_test.go

* fix import order
2025-04-23 23:35:05 -07:00

38 lines
1003 B
Go

//go:build darwin || (linux && amd64)
// +build darwin linux,amd64
package snapmeta
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/kopia/kopia/tests/robustness"
)
func TestSimpleBasic(t *testing.T) {
ctx := context.Background()
simple := NewSimple()
gotData, err := simple.Load(ctx, "non-existent-key")
require.ErrorIs(t, err, robustness.ErrKeyNotFound, "Did not get expected error")
require.Nil(t, gotData, "Expecting nil data return from a key that does not exist")
storeKey := "key-to-store"
data := []byte("some stored data")
simple.Store(ctx, storeKey, data)
gotData, err = simple.Load(ctx, storeKey)
require.NoError(t, err, "Error getting key")
require.Equal(t, data, gotData, "Did not get the correct data")
simple.Delete(ctx, storeKey)
gotData, err = simple.Load(ctx, storeKey)
require.ErrorIs(t, err, robustness.ErrKeyNotFound, "Did not get expected error")
require.Nil(t, gotData, "Expecting nil data return from a deleted key")
}