mirror of
https://github.com/valitydev/botkube.git
synced 2024-11-06 08:25:19 +00:00
added a testcase for skipping delete event for namespace not configured (#400)
##### ISSUE TYPE <!--- Pick one below and delete the rest: --> - Bug fix Pull Request ##### SUMMARY <!--- Describe the change, including rationale and design decisions --> Added skip delete event test case that should be skipped for namespaces which are not configured for delete event in test config. Modified the resource configuration map AllowedEventKindsMap and removed delete event for namespace test. <!--- If you are fixing an existing issue, please include "Fixes #nnn" in your PR comment; and describe briefly what the change does. --> <!--- Please list dependencies added with your change also --> Fixes test case - Validate that delete events are skipped when an event occurs for a namespace which is not configured of issue #354
This commit is contained in:
parent
39fa7499b8
commit
1c70be3e7e
@ -24,9 +24,18 @@ type context struct {
|
||||
func (c *context) testSKipDeleteEvent(t *testing.T) {
|
||||
// Modifying AllowedEventKindsMap to remove delete event for pod resource
|
||||
delete(utils.AllowedEventKindsMap, utils.EventKind{Resource: "v1/pods", Namespace: "all", EventType: "delete"})
|
||||
// Modifying AllowedEventKindsMap to add delete event for only dummy namespace and ignore everything
|
||||
utils.AllowedEventKindsMap[utils.EventKind{Resource: "v1/pods", Namespace: "dummy", EventType: "delete"}] = true
|
||||
// test scenarios
|
||||
tests := map[string]testutils.DeleteObjects{
|
||||
"skip delete event for resources not configured": {
|
||||
// delete operation not allowed for Pod resources so event should be skipped
|
||||
GVR: schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"},
|
||||
Kind: "Pod",
|
||||
Namespace: "test",
|
||||
Specs: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "test-pod-delete"}, Spec: v1.PodSpec{Containers: []v1.Container{{Name: "test-pod-container", Image: "tomcat:9.0.34"}}}},
|
||||
},
|
||||
"skip delete event for namespace not configured": {
|
||||
// delete operation not allowed for Pod in test namespace so event should be skipped
|
||||
GVR: schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"},
|
||||
Kind: "Pod",
|
||||
@ -51,6 +60,7 @@ func (c *context) testSKipDeleteEvent(t *testing.T) {
|
||||
})
|
||||
}
|
||||
// Resetting original configuration as per test_config
|
||||
defer delete(utils.AllowedEventKindsMap, utils.EventKind{Resource: "v1/pods", Namespace: "dummy", EventType: "delete"})
|
||||
utils.AllowedEventKindsMap[utils.EventKind{Resource: "v1/pods", Namespace: "all", EventType: "delete"}] = true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user