Add test for IsHelm3 logic.
This commit is contained in:
		
							parent
							
								
									d15c4aad2d
								
							
						
					
					
						commit
						dc2961a493
					
				|  | @ -20,7 +20,7 @@ type mockRunner struct { | |||
| } | ||||
| 
 | ||||
| func (mock *mockRunner) Execute(cmd string, args []string, env map[string]string) ([]byte, error) { | ||||
| 	return []byte{}, nil | ||||
| 	return mock.output, mock.err | ||||
| } | ||||
| 
 | ||||
| func MockExecer(logger *zap.SugaredLogger, kubeContext string) *execer { | ||||
|  | @ -506,3 +506,17 @@ exec: helm template path/to/chart --name release --values file.yml --kube-contex | |||
| 		t.Errorf("helmexec.Template()\nactual = %v\nexpect = %v", buffer.String(), expected) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func Test_IsHelm3(t *testing.T) { | ||||
| 	helm2Runner := mockRunner{output: []byte("Client: v2.16.0+ge13bc94\n")} | ||||
| 	helm := New("helm", NewLogger(os.Stdout, "info"), "dev", &helm2Runner) | ||||
| 	if helm.IsHelm3() { | ||||
| 		t.Error("helmexec.IsHelm3() - Detected Helm 3 with Helm 2 version") | ||||
| 	} | ||||
| 
 | ||||
| 	helm3Runner := mockRunner{output: []byte("v3.0.0+ge29ce2a\n")} | ||||
| 	helm = New("helm", NewLogger(os.Stdout, "info"), "dev", &helm3Runner) | ||||
| 	if !helm.IsHelm3() { | ||||
| 		t.Error("helmexec.IsHelm3() - Failed to detect Helm 3") | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue