add delete document test
This commit is contained in:
parent
3c1a96c8e0
commit
c8034066c9
22
db_test.go
22
db_test.go
|
@ -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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue