Skip to content

Commit

Permalink
feat(service_test.go): add validateListContents function to enhance t…
Browse files Browse the repository at this point in the history
…esting capabilities

The new function `validateListContents` is introduced to streamline the
validation of content list properties in tests. It uses a structured
approach by accepting parameters in a struct, allowing for more
organized and readable tests.
  • Loading branch information
cybersiddhu committed Aug 15, 2024
1 parent eec7386 commit cd8fcb2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions internal/app/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,28 @@ func TestDeleteContent(t *testing.T) {
assert.NoError(err, "expect no error from deleting content")
}

type validateListContentsParams struct {
Assert *require.Assertions
Data []*content.ContentCollection_Data
NameRegex *regexp.Regexp
Namespace string
}

func validateListContents(params validateListContentsParams) {
for _, cnt := range params.Data {
params.Assert.Regexp(
params.NameRegex,
cnt.Attributes.Name,
"name should match",
)
params.Assert.Equal(
cnt.Attributes.Namespace,
params.Namespace,
"namespace should match",
)
}
}

func testContentProperties(
assert *require.Assertions,
sct, nct *content.Content,
Expand Down

0 comments on commit cd8fcb2

Please sign in to comment.