Skip to content

Conversation

romoh
Copy link
Contributor

@romoh romoh commented Jun 24, 2025

Improve code coverage

fixes #279


Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • Code conforms to style guidelines

Signed-off-by: Roaa Sakr <[email protected]>
@romoh romoh marked this pull request as ready for review June 24, 2025 16:33
@romoh romoh requested a review from a team as a code owner June 24, 2025 16:33
@romoh romoh changed the title Add unit tests for previewFeature Add unittests for previewFeature Jun 24, 2025
invalidFeature := PreviewFeature("invalid-feature")
err := invalidFeature.IsValid()
assert.Error(t, err)
assert.Contains(t, err.Error(), "invalid-feature")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assert.ErrorContains instead of assert.Error and assert.Contains.

assert.Error(t, err)
assert.Contains(t, err.Error(), "invalid-feature")

// Test PreviewFeatureReinitializeVerity is not valid (since it's not typed as PreviewFeature)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why this fails is because PreviewFeatureReinitializeVerity is missing in the PreviewFeature.IsValid() function. Go is happily doing the type-cast without issue.

Also, it looks like the Config.PreviewFeatures field isn't being checked for validity. Hence, why this wasn't causing any problems.

@cwize1 cwize1 closed this Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for PreviewFeature
2 participants