generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove the mutating and validating webhooks for v1alpha2 Subscr…
…iption (#549) * feat: remove the mutating and validating webhooks for v1alpha2 Subscription. * Fix lint issues * Revert image update * Fix tests * Refactor subscription validation * Fix lint issues * Refactor subscription validation * Refactoring * Add subscription validation tests * Test subscription validation in the reconciler using mocks * Fix lint issues * Refactoring * Refactor type matching validation * Refactoring validation * Undo doc changes * Update validation tests * Add defaulting tests * Remove not needed setup * Update defaulting expr * Fix lint issues * Add tests for webhook resources cleanup * Add tests for subscription spec valid conditions * Restrict delete job and cronjobs only to the target resources * Fix lint issues * Preserve the old subscription status in case of the EventMesh backend * Fix generated config * Remove webhook cleanup logic
- Loading branch information
1 parent
ae794df
commit f71e3c4
Showing
68 changed files
with
1,635 additions
and
2,462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package v1alpha2 | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
kcorev1 "k8s.io/api/core/v1" | ||
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func Test_makeSubscriptionSpecValidCondition(t *testing.T) { | ||
t.Parallel() | ||
|
||
var ( | ||
// subscription spec valid condition | ||
subscriptionSpecValidTrueCondition = Condition{ | ||
Type: ConditionSubscriptionSpecValid, | ||
Status: kcorev1.ConditionTrue, | ||
LastTransitionTime: kmetav1.Now(), | ||
Reason: ConditionReasonSubscriptionSpecHasNoValidationErrors, | ||
Message: "", | ||
} | ||
|
||
// subscription spec invalid condition | ||
subscriptionSpecValidFalseCondition = Condition{ | ||
Type: ConditionSubscriptionSpecValid, | ||
Status: kcorev1.ConditionFalse, | ||
LastTransitionTime: kmetav1.Now(), | ||
Reason: ConditionReasonSubscriptionSpecHasValidationErrors, | ||
Message: "some error", | ||
} | ||
) | ||
|
||
tests := []struct { | ||
name string | ||
givenError error | ||
wantSubscriptionSpecValidCondition Condition | ||
}{ | ||
{ | ||
name: "no error", | ||
givenError: nil, | ||
wantSubscriptionSpecValidCondition: subscriptionSpecValidTrueCondition, | ||
}, | ||
{ | ||
name: "error", | ||
givenError: errors.New("some error"), //nolint: goerr113 // used for testing only | ||
wantSubscriptionSpecValidCondition: subscriptionSpecValidFalseCondition, | ||
}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
// when | ||
gotCondition := makeSubscriptionSpecValidCondition(test.givenError) | ||
|
||
// then | ||
require.True(t, ConditionEquals(gotCondition, test.wantSubscriptionSpecValidCondition)) | ||
}) | ||
} | ||
} |
Oops, something went wrong.