From 4221f8cf2cee96d27b322885fb5f5f5dc6749883 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 21 Nov 2019 22:29:58 +0100 Subject: [PATCH] test internal/config trick to have a 100% coverage (as conflict check is undeterministic, merge all conditions) --- internal/config/config_test.go | 4 +++- internal/config/method.go | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 466cec2..deb3170 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -490,7 +490,9 @@ func TestParseParameters(t *testing.T) { if err != nil && test.Error != nil { if err.Error() != test.Error.Error() && err.Error() != test.ErrorAlternative.Error() { - t.Errorf("expected the error '%s' (got '%s')", test.Error.Error(), err.Error()) + t.Errorf("got the error: '%s'", err.Error()) + t.Errorf("expected error (alternative 1): '%s'", test.Error.Error()) + t.Errorf("expected error (alternative 2): '%s'", test.ErrorAlternative.Error()) t.FailNow() } } diff --git a/internal/config/method.go b/internal/config/method.go index 802766d..14c3539 100644 --- a/internal/config/method.go +++ b/internal/config/method.go @@ -39,17 +39,9 @@ func (methodDef *Method) checkAndFormat(servicePath string, httpMethod string) e } // 3.2.1. Same rename field - if pData.Rename == param.Rename { - return ErrParamNameConflict.WrapString(httpMethod + " " + servicePath + " {" + pName + "}") - } - // 3.2.2. Not-renamed field matches a renamed field - if pName == param.Rename { - return ErrParamNameConflict.WrapString(httpMethod + " " + servicePath + " {" + pName + "}") - } - // 3.2.3. Renamed field matches name - if pData.Rename == paramName { + if pData.Rename == param.Rename || pName == param.Rename || pData.Rename == paramName { return ErrParamNameConflict.WrapString(httpMethod + " " + servicePath + " {" + pName + "}") }