Lint code using staticcheck (#4471)
This commit is contained in:
parent
8f09acac2b
commit
fcd3054f13
16 changed files with 32 additions and 41 deletions
|
|
@ -79,7 +79,7 @@ func TestParseEmptyFastCGIAnnotations(t *testing.T) {
|
|||
t.Errorf("Index should be an empty string")
|
||||
}
|
||||
|
||||
if 0 != len(config.Params) {
|
||||
if len(config.Params) != 0 {
|
||||
t.Errorf("Params should be an empty slice")
|
||||
}
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ func TestParseEmptyFastCGIParamsConfigMapAnnotation(t *testing.T) {
|
|||
t.Errorf("Parse do not return a Config object")
|
||||
}
|
||||
|
||||
if 0 != len(config.Params) {
|
||||
if len(config.Params) != 0 {
|
||||
t.Errorf("Params should be an empty slice")
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ func TestParseFastCGIInvalidParamsConfigMapAnnotation(t *testing.T) {
|
|||
t.Errorf("Parse do not return a Config object")
|
||||
}
|
||||
|
||||
if 0 != len(config.Params) {
|
||||
if len(config.Params) != 0 {
|
||||
t.Errorf("Params should be an empty slice")
|
||||
}
|
||||
}
|
||||
|
|
@ -173,11 +173,11 @@ func TestParseFastCGIParamsConfigMapAnnotationWithoutNS(t *testing.T) {
|
|||
t.Errorf("Parse do not return a Config object")
|
||||
}
|
||||
|
||||
if 2 != len(config.Params) {
|
||||
if len(config.Params) != 2 {
|
||||
t.Errorf("Params should have a length of 2")
|
||||
}
|
||||
|
||||
if "200" != config.Params["REDIRECT_STATUS"] || "$server_name" != config.Params["SERVER_NAME"] {
|
||||
if config.Params["REDIRECT_STATUS"] != "200" || config.Params["SERVER_NAME"] != "$server_name" {
|
||||
t.Errorf("Params value is not the one expected")
|
||||
}
|
||||
}
|
||||
|
|
@ -199,11 +199,11 @@ func TestParseFastCGIParamsConfigMapAnnotationWithNS(t *testing.T) {
|
|||
t.Errorf("Parse do not return a Config object")
|
||||
}
|
||||
|
||||
if 2 != len(config.Params) {
|
||||
if len(config.Params) != 2 {
|
||||
t.Errorf("Params should have a length of 2")
|
||||
}
|
||||
|
||||
if "200" != config.Params["REDIRECT_STATUS"] || "$server_name" != config.Params["SERVER_NAME"] {
|
||||
if config.Params["REDIRECT_STATUS"] != "200" || config.Params["SERVER_NAME"] != "$server_name" {
|
||||
t.Errorf("Params value is not the one expected")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,13 +295,13 @@ func TestConfigureDynamically(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("unexpected error posting dynamic configuration: %v", err)
|
||||
}
|
||||
if count, _ := endpointStats["/configuration/backends"]; count != 0 {
|
||||
if count := endpointStats["/configuration/backends"]; count != 0 {
|
||||
t.Errorf("Expected %v to receive %d requests but received %d.", "/configuration/backends", 0, count)
|
||||
}
|
||||
if count, _ := endpointStats["/configuration/servers"]; count != 0 {
|
||||
if count := endpointStats["/configuration/servers"]; count != 0 {
|
||||
t.Errorf("Expected %v to receive %d requests but received %d.", "/configuration/servers", 0, count)
|
||||
}
|
||||
if count, _ := endpointStats["/configuration/general"]; count != 1 {
|
||||
if count := endpointStats["/configuration/general"]; count != 1 {
|
||||
t.Errorf("Expected %v to receive %d requests but received %d.", "/configuration/general", 0, count)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,10 +217,8 @@ func quote(input interface{}) string {
|
|||
switch input := input.(type) {
|
||||
case string:
|
||||
inputStr = input
|
||||
break
|
||||
case fmt.Stringer:
|
||||
inputStr = input.String()
|
||||
break
|
||||
default:
|
||||
inputStr = fmt.Sprintf("%v", input)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,7 +220,11 @@ func TestBuildLuaSharedDictionaries(t *testing.T) {
|
|||
}
|
||||
// test invalid config
|
||||
configuration = buildLuaSharedDictionaries(invalidType, servers, false)
|
||||
if expected != actual {
|
||||
if configuration != "" {
|
||||
t.Errorf("expected an empty string, but got %s", configuration)
|
||||
}
|
||||
|
||||
if actual != expected {
|
||||
t.Errorf("Expected '%v' but returned '%v' ", expected, actual)
|
||||
}
|
||||
}
|
||||
|
|
@ -233,7 +237,7 @@ func TestLuaConfigurationRequestBodySize(t *testing.T) {
|
|||
}
|
||||
|
||||
size := luaConfigurationRequestBodySize(cfg)
|
||||
if "21" != size {
|
||||
if size != "21" {
|
||||
t.Errorf("expected the size to be 20 but got: %v", size)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type Backend struct {
|
|||
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors
|
||||
// http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
|
||||
// By default this is disabled
|
||||
CustomHTTPErrors []int `json:"custom-http-errors,-"`
|
||||
CustomHTTPErrors []int `json:"custom-http-errors"`
|
||||
|
||||
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
|
||||
// Sets the maximum allowed size of the client request body
|
||||
|
|
@ -102,7 +102,7 @@ type Backend struct {
|
|||
// SkipAccessLogURLs sets a list of URLs that should not appear in the NGINX access log
|
||||
// This is useful with urls like `/health` or `health-check` that make "complex" reading the logs
|
||||
// By default this list is empty
|
||||
SkipAccessLogURLs []string `json:"skip-access-log-urls,-"`
|
||||
SkipAccessLogURLs []string `json:"skip-access-log-urls"`
|
||||
|
||||
// Enables or disables the redirect (301) to the HTTPS port
|
||||
SSLRedirect bool `json:"ssl-redirect"`
|
||||
|
|
@ -134,7 +134,7 @@ type Backend struct {
|
|||
|
||||
// WhitelistSourceRange allows limiting access to certain client addresses
|
||||
// http://nginx.org/en/docs/http/ngx_http_access_module.html
|
||||
WhitelistSourceRange []string `json:"whitelist-source-range,-"`
|
||||
WhitelistSourceRange []string `json:"whitelist-source-range"`
|
||||
|
||||
// Limits the rate of response transmission to a client.
|
||||
// The rate is specified in bytes per second. The zero value disables rate limiting.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue