(t *testing.T)
| 273 | } |
| 274 | |
| 275 | func TestDelete(t *testing.T) { |
| 276 | testCases := []deleteTestCase{ |
| 277 | { |
| 278 | name: "delete with one manifest", |
| 279 | manifests: []string{"oneManifest"}, |
| 280 | cmdPath: "myPath", |
| 281 | expectedPaths: []string{"myPath", "myPath"}, |
| 282 | expectedArgs: [][]string{ |
| 283 | {"create", "--dry-run", "--output", "yaml", "--validate=false", "--filename", "oneManifest"}, |
| 284 | {"delete", "--ignore-not-found=true", "-f", "-"}, |
| 285 | }, |
| 286 | }, |
| 287 | } |
| 288 | |
| 289 | for _, testCase := range testCases { |
| 290 | cache := localcache.New("") |
| 291 | deployer := &DeployConfig{ |
| 292 | CmdPath: testCase.cmdPath, |
| 293 | Manifests: testCase.manifests, |
| 294 | DeploymentConfig: &latest.DeploymentConfig{ |
| 295 | Name: "someDeploy", |
| 296 | Kubectl: &latest.KubectlConfig{ |
| 297 | Kustomize: &testCase.kustomize, |
| 298 | }, |
| 299 | }, |
| 300 | } |
| 301 | |
| 302 | if testCase.cache == nil { |
| 303 | testCase.cache = &remotecache.RemoteCache{} |
| 304 | } |
| 305 | |
| 306 | conf := config.NewConfig(map[string]interface{}{}, |
| 307 | map[string]interface{}{}, |
| 308 | &latest.Config{}, |
| 309 | cache, |
| 310 | &remotecache.RemoteCache{}, |
| 311 | map[string]interface{}{}, |
| 312 | constants.DefaultConfigPath) |
| 313 | |
| 314 | devCtx := devspacecontext.NewContext(context.Background(), nil, log.NewFakeLogger()).WithConfig(conf) |
| 315 | |
| 316 | err := Delete(devCtx, deployer.DeploymentConfig.Name) |
| 317 | if testCase.expectedErr == "" { |
| 318 | assert.NilError(t, err, "Error in testCase %s", testCase.name) |
| 319 | } else { |
| 320 | assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name) |
| 321 | } |
| 322 | |
| 323 | // statusAsYaml, err := yaml.Marshal(testCase.cache.Deployments) |
| 324 | // assert.NilError(t, err, "Error marshaling status in testCase %s", testCase.name) |
| 325 | // expectedAsYaml, err := yaml.Marshal(testCase.expectedDeployments) |
| 326 | // assert.NilError(t, err, "Error marshaling expected status in testCase %s", testCase.name) |
| 327 | // assert.Equal(t, string(statusAsYaml), string(expectedAsYaml), "Unexpected status in testCase %s", testCase.name) |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | type deployTestCase struct { |
| 332 | name string |
nothing calls this directly
no test coverage detected