MCPcopy
hub / github.com/roboll/helmfile / Test_AddRepo

Function Test_AddRepo

pkg/helmexec/exec_test.go:105–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func Test_AddRepo(t *testing.T) {
106 var buffer bytes.Buffer
107 logger := NewLogger(&buffer, "debug")
108 helm := MockExecer(logger, "dev")
109 err := helm.AddRepo("myRepo", "https://repo.example.com/", "", "cert.pem", "key.pem", "", "", "", "", "")
110 expected := `Adding repo myRepo https://repo.example.com/
111exec: helm --kube-context dev repo add myRepo https://repo.example.com/ --cert-file cert.pem --key-file key.pem
112`
113 if err != nil {
114 t.Errorf("unexpected error: %v", err)
115 }
116
117 if buffer.String() != expected {
118 t.Errorf("helmexec.AddRepo()\nactual = %v\nexpect = %v", buffer.String(), expected)
119 }
120
121 buffer.Reset()
122 err = helm.AddRepo("myRepo", "https://repo.example.com/", "ca.crt", "", "", "", "", "", "", "")
123 expected = `Adding repo myRepo https://repo.example.com/
124exec: helm --kube-context dev repo add myRepo https://repo.example.com/ --ca-file ca.crt
125`
126 if err != nil {
127 t.Errorf("unexpected error: %v", err)
128 }
129
130 if buffer.String() != expected {
131 t.Errorf("helmexec.AddRepo()\nactual = %v\nexpect = %v", buffer.String(), expected)
132 }
133
134 buffer.Reset()
135 err = helm.AddRepo("myRepo", "https://repo.example.com/", "", "", "", "", "", "", "", "")
136 expected = `Adding repo myRepo https://repo.example.com/
137exec: helm --kube-context dev repo add myRepo https://repo.example.com/
138`
139 if err != nil {
140 t.Errorf("unexpected error: %v", err)
141 }
142
143 if buffer.String() != expected {
144 t.Errorf("helmexec.AddRepo()\nactual = %v\nexpect = %v", buffer.String(), expected)
145 }
146
147 buffer.Reset()
148 err = helm.AddRepo("acrRepo", "", "", "", "", "", "", "acr", "", "")
149 expected = `Adding repo acrRepo (acr)
150exec: az acr helm repo add --name acrRepo
151exec: az acr helm repo add --name acrRepo:
152`
153 if err != nil {
154 t.Errorf("unexpected error: %v", err)
155 }
156
157 if buffer.String() != expected {
158 t.Errorf("helmexec.AddRepo()\nactual = %v\nexpect = %v", buffer.String(), expected)
159 }
160
161 buffer.Reset()
162 err = helm.AddRepo("otherRepo", "", "", "", "", "", "", "unknown", "", "")

Callers

nothing calls this directly

Calls 4

NewLoggerFunction · 0.85
MockExecerFunction · 0.70
AddRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected