Parcourir la source

Add test for config file and fix IsKubernetesEnabled() tests

Signed-off-by: Matt Ray <github@mattray.dev>
Matt Ray il y a 2 ans
Parent
commit
16c56043b1
1 fichiers modifiés avec 40 ajouts et 2 suppressions
  1. 40 2
      pkg/env/costmodelenv_test.go

+ 40 - 2
pkg/env/costmodelenv_test.go

@@ -138,14 +138,14 @@ func TestGetKubernetesEnabled(t *testing.T) {
 			name: "Ensure the value is true when KUBERNETES_ENABLED is set to true",
 			want: true,
 			pre: func() {
-				os.Setenv("EXPORT_KUBERNETES_ENABLED", "true")
+				os.Setenv("KUBERNETES_ENABLED", "true")
 			},
 		},
 		{
 			name: "Ensure the value is false when KUBERNETES_ENABLED is set to false",
 			want: false,
 			pre: func() {
-				os.Setenv("EXPORT_KUBERNETES_ENABLED", "false")
+				os.Setenv("KUBERNETES_ENABLED", "false")
 			},
 		},
 	}
@@ -161,3 +161,41 @@ func TestGetKubernetesEnabled(t *testing.T) {
 	}
 
 }
+
+func TestGetCloudIntegrationSecretPath(t *testing.T) {
+	tests := []struct {
+		name string
+		want string
+		pre  func()
+	}{
+		{
+			name: "Ensure the default value is 'cloud-integration.json'",
+			want: "cloud-integration.json",
+		},
+		{
+			name: "Ensure the value is 'cloud-integration.json' when CLOUD_INTEGRATION_SECRET_PATH is set to ''",
+			want: "cloud-integration.json",
+			pre: func() {
+				os.Setenv("CLOUD_INTEGRATION_SECRET_PATH", "")
+			},
+		},
+		{
+			name: "Ensure the value is 'flying-pig.json' when CLOUD_INTEGRATION_SECRET_PATH is set to 'flying-pig.json'",
+			want: "flying-pig.json",
+			pre: func() {
+				os.Setenv("CLOUD_INTEGRATION_SECRET_PATH", "flying-pig.json")
+			},
+		},
+	}
+	for _, tt := range tests {
+		if tt.pre != nil {
+			tt.pre()
+		}
+		t.Run(tt.name, func(t *testing.T) {
+			if got := GetCloudIntegrationSecretPath(); got != tt.want {
+				t.Errorf("GetCloudIntegrationSecretPath() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+
+}