(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func TestPurge(t *testing.T) { |
| 224 | testCases := []purgeTestCase{ |
| 225 | { |
| 226 | name: "Skip deployment", |
| 227 | deploymentConfigs: map[string]*latest.DeploymentConfig{ |
| 228 | "skippedDeployment": { |
| 229 | Name: "skippedDeployment", |
| 230 | }, |
| 231 | }, |
| 232 | deploymentNames: []string{"unskippedDeployment"}, |
| 233 | }, |
| 234 | { |
| 235 | name: "No deployment method", |
| 236 | deploymentConfigs: map[string]*latest.DeploymentConfig{ |
| 237 | "noMethod": { |
| 238 | Name: "noMethod", |
| 239 | }, |
| 240 | }, |
| 241 | deploymentNames: []string{"noMethod"}, |
| 242 | expectedErr: "error purging: deployment noMethod has no deployment method", |
| 243 | }, |
| 244 | { |
| 245 | name: "Deploy with kubectl", |
| 246 | deploymentConfigs: map[string]*latest.DeploymentConfig{ |
| 247 | "kubectlDeploy": { |
| 248 | Name: "kubectlDeploy", |
| 249 | Kubectl: &latest.KubectlConfig{ |
| 250 | Manifests: []string{}, |
| 251 | }, |
| 252 | }, |
| 253 | }, deploymentNames: []string{"kubectlDeploy"}, |
| 254 | }, |
| 255 | } |
| 256 | |
| 257 | for _, testCase := range testCases { |
| 258 | kube := fake.NewSimpleClientset() |
| 259 | kubeClient := &fakekube.Client{ |
| 260 | Client: kube, |
| 261 | } |
| 262 | config := &latest.Config{ |
| 263 | Deployments: testCase.deploymentConfigs, |
| 264 | } |
| 265 | |
| 266 | controller := NewController() |
| 267 | conf := config2.NewConfig(map[string]interface{}{}, |
| 268 | map[string]interface{}{}, |
| 269 | config, |
| 270 | &localcache.LocalCache{}, |
| 271 | remotecache.NewCache("", "test"), |
| 272 | map[string]interface{}{}, |
| 273 | constants.DefaultConfigPath) |
| 274 | devCtx := devspacecontext.NewContext(context.TODO(), nil, log.Discard).WithKubeClient(kubeClient).WithConfig(conf) |
| 275 | err := controller.Purge(devCtx, testCase.deploymentNames, &PurgeOptions{}) |
| 276 | |
| 277 | assert.NilError(t, err) |
| 278 | } |
| 279 | } |
nothing calls this directly
no test coverage detected