add delete document test
All checks were successful
Go / build (1.21) (push) Successful in 1m3s
Go / build (1.22) (push) Successful in 1m1s

This commit is contained in:
saji 2024-03-07 07:34:55 -06:00
parent 3c1a96c8e0
commit c8034066c9

View file

@ -281,4 +281,26 @@ func TestDbDocuments(t *testing.T) {
} }
}) })
t.Run("test delete document", func(t *testing.T) {
tdb := MakeMockDatabase(t.Name())
tdb.db.Ping()
ctx := context.Background()
doc := MockDocument("hi")
tdb.AddDocument(ctx, doc)
err := tdb.DeleteDocument(ctx, "hi")
if err != nil {
t.Fatalf("DeleteDocument expected no error, got err=%v", err)
}
})
t.Run("test delete nonexistent document", func(t *testing.T) {
tdb := MakeMockDatabase(t.Name())
tdb.db.Ping()
ctx := context.Background()
err := tdb.DeleteDocument(ctx, "hi")
if !errors.Is(err, DocumentNotFoundError("hi")) {
t.Fatalf("DeleteDocument expected not found, got err=%v", err)
}
})
} }