Files
kopia/tests/robustness/snapmeta/index_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

31 lines
577 B
Go

//go:build darwin || (linux && amd64)
// +build darwin linux,amd64
package snapmeta
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIndex(t *testing.T) {
idx := Index{}
const (
snapshotIndexName = "snapshotIndex"
snapIDKey = "snapID1"
)
idx.AddToIndex(snapIDKey, snapshotIndexName)
keys := idx.GetKeys(snapshotIndexName)
require.Len(t, keys, 1, "unexpected number of keys")
require.Equal(t, snapIDKey, keys[0])
idx.RemoveFromIndex(snapIDKey, snapshotIndexName)
keys = idx.GetKeys(snapshotIndexName)
require.Empty(t, keys)
}