Skip to content
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

added test for skip delete event when resources are not added in test_config #405

Conversation

akankshakumari393
Copy link
Contributor

ISSUE TYPE
  • Bug fix Pull Request
SUMMARY

Added skip delete event test case that should be skipped if event occurred for a resource which is not added in test configuration.
Modified AllowedEventKindsMap to removed the v1/services resource

Fixes test case - Validate that delete events are skipped when an event occurs for a resource which is not added in resource_config of issue #354

@PrasadG193
Copy link
Collaborator

@A-kanksh-a should we wrap the conditions to check if an event is allowed in functions and use that in tests?
e.g

utils.AllowedEventKindsMap[utils.EventKind{
				Resource:  resource,
				Namespace: "all",
				EventType: config.DeleteEvent}] ||
				utils.AllowedEventKindsMap[utils.EventKind{
					Resource:  resource,
					Namespace: test.Namespace,
					EventType: config.DeleteEvent}]

@akankshakumari393
Copy link
Contributor Author

@A-kanksh-a should we wrap the conditions to check if an event is allowed in functions and use that in tests?
e.g

utils.AllowedEventKindsMap[utils.EventKind{
				Resource:  resource,
				Namespace: "all",
				EventType: config.DeleteEvent}] ||
				utils.AllowedEventKindsMap[utils.EventKind{
					Resource:  resource,
					Namespace: test.Namespace,
					EventType: config.DeleteEvent}]

@PrasadG193 will do the changes.

@@ -149,3 +149,17 @@ func DeleteResource(t *testing.T, obj DeleteObjects) {
t.Fatalf("Failed to delete %s: %v", obj.GVR.Resource, err)
}
}

// CheckOperationAllowed checks whether operation are allowed
func CheckOperationAllowed(eventMap map[utils.EventKind]bool, namespace string, resource string, eventType config.EventType) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@A-kanksh-a I meant to add this function in pkg/utils and use it in controller.go as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we can do that.


// CheckOperationAllowed checks whether operation are allowed
func CheckOperationAllowed(eventMap map[EventKind]bool, namespace string, resource string, eventType config.EventType) bool {
if eventMap[EventKind{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please check if eventMap is nil before accessing the fields

test/e2e/notifier/create/create.go Outdated Show resolved Hide resolved
@mergify mergify bot merged commit c4604a6 into kubeshop:develop Oct 14, 2020
@chetanpdeshmukh
Copy link

Hello @A-kanksh-a ,
Thanks again for the PR!

Thank you for contributing to BotKube. Could you please fill out this form, so we can send the well deserved awesome swags 🙂

Team BotKube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants