From 5ec069a02375f4868dbff584bd9cd049e4bcd753 Mon Sep 17 00:00:00 2001 From: Paige Rubendall Date: Wed, 29 Nov 2023 13:38:54 -0500 Subject: [PATCH] all namespaces --- src/krkn_lib/tests/test_krkn_kubernetes.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/krkn_lib/tests/test_krkn_kubernetes.py b/src/krkn_lib/tests/test_krkn_kubernetes.py index 067970e7..17481aa4 100644 --- a/src/krkn_lib/tests/test_krkn_kubernetes.py +++ b/src/krkn_lib/tests/test_krkn_kubernetes.py @@ -72,6 +72,25 @@ def test_get_kubeconfig_path(self): test_kubeconfig = test.read() self.assertEqual(test_kubeconfig, kubeconfig_str) + + def test_list_all_namespaces(self): + # test list all namespaces + result = self.lib_k8s.list_all_namespaces() + self.assertTrue(len(result) > 1) + # test filter by label + result = self.lib_k8s.list_all_namespaces( + "kubernetes.io/metadata.name=default" + ) + print('result type' + str(type(result))) + self.assertTrue(len(result) == 1) + self.assertIn("default", result) + + # test unexisting filter + result = self.lib_k8s.list_namespaces( + "k8s.io/metadata.name=donotexist" + ) + self.assertTrue(len(result) == 0) + def test_list_namespaces(self): # test all namespaces result = self.lib_k8s.list_namespaces()