(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestDelete(t *testing.T) { |
| 34 | testCases := []deleteTestCase{ |
| 35 | { |
| 36 | name: "delete deployment", |
| 37 | releasesBefore: []*helmtypes.Release{ |
| 38 | { |
| 39 | Name: "deleteThisRelease", |
| 40 | }, |
| 41 | }, |
| 42 | deployment: "deleteThisRelease", |
| 43 | chart: "deleteThisDeployment", |
| 44 | cache: &remotecache.RemoteCache{ |
| 45 | Deployments: []remotecache.DeploymentCache{ |
| 46 | { |
| 47 | Name: "deleteThisDeployment", |
| 48 | }, |
| 49 | }, |
| 50 | }, |
| 51 | }, |
| 52 | } |
| 53 | |
| 54 | for _, testCase := range testCases { |
| 55 | kube := fake.NewSimpleClientset() |
| 56 | kubeClient := &fakekube.Client{ |
| 57 | Client: kube, |
| 58 | } |
| 59 | |
| 60 | if testCase.cache == nil { |
| 61 | testCase.cache = &remotecache.RemoteCache{} |
| 62 | } |
| 63 | |
| 64 | cg := config.NewConfig(map[string]interface{}{}, map[string]interface{}{}, latest.NewRaw(), localcache.New(""), testCase.cache, map[string]interface{}{}, constants.DefaultConfigsPath) |
| 65 | devContext := devspacecontext.NewContext(context.Background(), nil, log.Discard).WithConfig(cg).WithKubeClient(kubeClient) |
| 66 | |
| 67 | err := Delete(devContext, testCase.deployment) |
| 68 | if testCase.expectedErr == "" { |
| 69 | assert.NilError(t, err, "Error in testCase %s", testCase.name) |
| 70 | } else { |
| 71 | assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name) |
| 72 | } |
| 73 | |
| 74 | // statusAsYaml, err := yaml.Marshal(testCase.cache.Deployments) |
| 75 | // assert.NilError(t, err, "Error marshaling status in testCase %s", testCase.name) |
| 76 | // expectedAsYaml, err := yaml.Marshal(testCase.expectedDeployments) |
| 77 | // assert.NilError(t, err, "Error marshaling expected status in testCase %s", testCase.name) |
| 78 | // assert.Equal(t, string(statusAsYaml), string(expectedAsYaml), "Unexpected status in testCase %s", testCase.name) |
| 79 | } |
| 80 | } |
nothing calls this directly
no test coverage detected