Skip to content

Commit

Permalink
test(arangodb_test.go): add test case for deleting content
Browse files Browse the repository at this point in the history
The new test case `TestDeleteContent` is added to test the functionality
of deleting content from the repository. It verifies that the content is
successfully deleted by checking if the content is not found after
deletion.
  • Loading branch information
cybersiddhu committed Nov 1, 2023
1 parent 8a9fa33 commit 8cf1b26
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/repository/arangodb/arangodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ func TestGetContent(t *testing.T) {
testContentProperties(assert, sct, nct)
}

func TestDeleteContent(t *testing.T) {
t.Parallel()
assert, repo := setUp(t)
defer tearDown(repo)
nct, err := repo.AddContent(NewStoreContent("catalog", "dsc"))
assert.NoErrorf(err, "expect no error from creating content %s", err)
key, err := strconv.ParseInt(nct.Key, 10, 64)
assert.NoErrorf(
err,
"expect no error from string to int64 conversion of key %s",
err,
)
err = repo.DeleteContent(key)
assert.NoErrorf(
err,
"expect no error from deleting content by slug %s",
err,
)
ecnt, err := repo.GetContent(key)
assert.NoErrorf(err, "expect no error from getting content by slug %s", err)
assert.True(ecnt.NotFound, "expect no record to be found")
}

func testContentProperties(
assert *require.Assertions,
sct, nct *model.ContentDoc,
Expand Down

0 comments on commit 8cf1b26

Please sign in to comment.