mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 08:15:48 -04:00
add namespace to kubectl requests (#315)
* add namespace to kubectl requests * Add tests for missing/wrong namespace Co-authored-by: Otto Bittner <cobittner@posteo.net>
This commit is contained in:
parent
c37fab0a4c
commit
e0ce2e8a51
6 changed files with 43 additions and 27 deletions
|
@ -77,12 +77,14 @@ var (
|
|||
}
|
||||
tolerationsDeployment = appsv1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-deployment",
|
||||
Namespace: "test-ns",
|
||||
Name: "test-deployment",
|
||||
},
|
||||
}
|
||||
selectorsDeployment = appsv1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-deployment",
|
||||
Namespace: "test-ns",
|
||||
Name: "test-deployment",
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Template: k8s.PodTemplateSpec{
|
||||
|
@ -300,15 +302,22 @@ func TestGetObjects(t *testing.T) {
|
|||
|
||||
func TestAddTolerationsToDeployment(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
namespace string
|
||||
name string
|
||||
tolerations []corev1.Toleration
|
||||
wantErr bool
|
||||
}{
|
||||
"Success": {
|
||||
name: "test-deployment",
|
||||
namespace: "test-ns",
|
||||
name: "test-deployment",
|
||||
},
|
||||
"Specifying non-existent deployment fails": {
|
||||
name: "wrong-name",
|
||||
namespace: "test-ns",
|
||||
name: "wrong-name",
|
||||
wantErr: true,
|
||||
},
|
||||
"Wrong namespace": {
|
||||
name: "test-deployment",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
@ -319,7 +328,7 @@ func TestAddTolerationsToDeployment(t *testing.T) {
|
|||
require := require.New(t)
|
||||
|
||||
client := newClientWithFakes(t, map[string]string{}, &tolerationsDeployment)
|
||||
err := client.AddTolerationsToDeployment(context.Background(), tc.tolerations, tc.name)
|
||||
err := client.AddTolerationsToDeployment(context.Background(), tc.tolerations, tc.name, tc.namespace)
|
||||
if tc.wantErr {
|
||||
assert.Error(err)
|
||||
return
|
||||
|
@ -331,16 +340,23 @@ func TestAddTolerationsToDeployment(t *testing.T) {
|
|||
|
||||
func TestAddNodeSelectorsToDeployment(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
namespace string
|
||||
name string
|
||||
selectors map[string]string
|
||||
wantErr bool
|
||||
}{
|
||||
"Success": {
|
||||
namespace: "test-ns",
|
||||
name: "test-deployment",
|
||||
selectors: map[string]string{"some-key": "some-value"},
|
||||
},
|
||||
"Specifying non-existent deployment fails": {
|
||||
name: "wrong-name",
|
||||
namespace: "test-ns",
|
||||
name: "wrong-name",
|
||||
wantErr: true,
|
||||
},
|
||||
"Wrong namespace": {
|
||||
name: "test-deployment",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
@ -351,7 +367,7 @@ func TestAddNodeSelectorsToDeployment(t *testing.T) {
|
|||
require := require.New(t)
|
||||
|
||||
client := newClientWithFakes(t, map[string]string{}, &selectorsDeployment)
|
||||
err := client.AddNodeSelectorsToDeployment(context.Background(), tc.selectors, tc.name)
|
||||
err := client.AddNodeSelectorsToDeployment(context.Background(), tc.selectors, tc.name, tc.namespace)
|
||||
if tc.wantErr {
|
||||
assert.Error(err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue