-
Notifications
You must be signed in to change notification settings - Fork 7
Add unittests for previewFeature #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package imagecustomizerapi | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPreviewFeature_IsValid(t *testing.T) { | ||
validFeatures := []PreviewFeature{ | ||
PreviewFeatureUki, | ||
PreviewFeatureOutputArtifacts, | ||
PreviewFeatureInjectFiles, | ||
PreviewFeaturePackageSnapshotTime, | ||
} | ||
|
||
for _, feature := range validFeatures { | ||
err := feature.IsValid() | ||
assert.NoError(t, err, "expected no error for valid feature: %s", feature) | ||
} | ||
|
||
invalidFeature := PreviewFeature("invalid-feature") | ||
err := invalidFeature.IsValid() | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "invalid-feature") | ||
|
||
// Test PreviewFeatureReinitializeVerity is not valid (since it's not typed as PreviewFeature) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason why this fails is because Also, it looks like the |
||
var reinitFeature PreviewFeature = PreviewFeatureReinitializeVerity | ||
err = reinitFeature.IsValid() | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "reinitialize-verity") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
assert.ErrorContains
instead ofassert.Error
andassert.Contains
.