(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func 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/ |
| 111 | exec: 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/ |
| 124 | exec: 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/ |
| 137 | exec: 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) |
| 150 | exec: az acr helm repo add --name acrRepo |
| 151 | exec: 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", "", "") |
nothing calls this directly
no test coverage detected