chore: improve assertions / coverage

This commit is contained in:
Milas Bowman 2025-03-09 22:28:16 -04:00
parent 0bdd3dfef8
commit 7d1910919c
Signed by: milas
SSH key fingerprint: SHA256:ek2D5l1HA34B3wbdErz0QOXm1E46CVvyf/nM4Fwfx/U
3 changed files with 66 additions and 31 deletions

View file

@ -39,14 +39,22 @@ func testContext(t testing.TB) context.Context {
return ctx
}
func randomKey() string {
return "key-" + strconv.Itoa(rand.IntN(1000000))
func randomKey(prefix string) string {
return prefix + "-" + strconv.Itoa(rand.IntN(1000000))
}
func randomPk() string {
return randomKey("pk")
}
func randomSk() string {
return randomKey("sk")
}
func TestClient_InsertItem(t *testing.T) {
t.Parallel()
f, ctx := newFixture(t)
err := f.cli.InsertItem(ctx, f.bucket, randomKey(), randomKey(), "", []byte("hello"))
err := f.cli.InsertItem(ctx, f.bucket, randomPk(), randomSk(), "", []byte("hello"))
require.NoError(t, err)
}
@ -54,8 +62,8 @@ func TestClient_ReadItemNotExist(t *testing.T) {
t.Parallel()
f, ctx := newFixture(t)
pk := randomKey()
sk := randomKey()
pk := randomPk()
sk := randomSk()
t.Run("Single", func(t *testing.T) {
t.Parallel()
@ -78,8 +86,8 @@ func TestClient_ReadItemTombstone(t *testing.T) {
t.Parallel()
f, ctx := newFixture(t)
pk := randomKey()
sk := randomKey()
pk := randomPk()
sk := randomSk()
t.Logf("Creating item: PK=%s, SK=%s", pk, sk)
@ -109,8 +117,8 @@ func TestClient_ReadItemSingleRevision(t *testing.T) {
t.Parallel()
f, ctx := newFixture(t)
pk := randomKey()
sk := randomKey()
pk := randomPk()
sk := randomSk()
err := f.cli.InsertItem(ctx, f.bucket, pk, sk, "", []byte("hello"))
require.NoError(t, err)
@ -137,8 +145,8 @@ func TestClient_ReadItemMultipleRevisions(t *testing.T) {
t.Parallel()
f, ctx := newFixture(t)
pk := randomKey()
sk := randomKey()
pk := randomPk()
sk := randomSk()
err := f.cli.InsertItem(ctx, f.bucket, pk, sk, "", []byte("hello1"))
require.NoError(t, err)