(t *testing.T)
| 174 | } |
| 175 | |
| 176 | func TestValidateAPIServerConfig(t *testing.T) { |
| 177 | cfg := getDefaultAPIServerConfig() |
| 178 | |
| 179 | tests := []struct { |
| 180 | name string |
| 181 | cfg APIServer |
| 182 | errString string |
| 183 | }{ |
| 184 | { |
| 185 | name: "Config is valid", |
| 186 | cfg: cfg, |
| 187 | errString: "", |
| 188 | }, |
| 189 | { |
| 190 | name: "Bind address is empty", |
| 191 | cfg: APIServer{ |
| 192 | Bind: "", |
| 193 | Port: 9998, |
| 194 | }, |
| 195 | errString: "invalid IP address", |
| 196 | }, |
| 197 | { |
| 198 | name: "Bind address is invalid", |
| 199 | cfg: APIServer{ |
| 200 | Bind: "not an IP", |
| 201 | Port: 9998, |
| 202 | }, |
| 203 | errString: "invalid IP address", |
| 204 | }, |
| 205 | { |
| 206 | name: "Bind address is valid IPv6", |
| 207 | cfg: APIServer{ |
| 208 | Bind: "::", |
| 209 | Port: 9998, |
| 210 | }, |
| 211 | errString: "", |
| 212 | }, |
| 213 | { |
| 214 | name: "Port is not set", |
| 215 | cfg: APIServer{ |
| 216 | Bind: cfg.Bind, |
| 217 | Port: 0, |
| 218 | }, |
| 219 | errString: "invalid port nr 0", |
| 220 | }, |
| 221 | { |
| 222 | name: "Port is not valid", |
| 223 | cfg: APIServer{ |
| 224 | Bind: cfg.Bind, |
| 225 | Port: 65536, |
| 226 | }, |
| 227 | errString: "invalid port nr 65536", |
| 228 | }, |
| 229 | { |
| 230 | name: "Invalid TLS config", |
| 231 | cfg: APIServer{ |
| 232 | Bind: cfg.Bind, |
| 233 | Port: cfg.Port, |
nothing calls this directly
no test coverage detected