From 8ba58b4748a64ff78411ecb5f823de96117d7cb2 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 21 Nov 2019 22:27:57 +0100 Subject: [PATCH] test internal/config empty parameter rename should not rename --- internal/config/config_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 3d0c19c..466cec2 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -209,6 +209,35 @@ func TestParseMissingMethodDescription(t *testing.T) { } +func TestParamEmptyRenameNoRename(t *testing.T) { + reader := strings.NewReader(`{ + "GET": { + "info": "info", + "in": { + "original": { "info": "valid-desc", "type": "valid-type", "name": "" } + } + } + }`) + srv, err := Parse(reader) + if err != nil { + t.Errorf("unexpected error: '%s'", err) + t.FailNow() + } + + method := srv.Method(http.MethodGet) + if method == nil { + t.Errorf("expected GET method not to be nil") + t.FailNow() + } + for _, param := range method.Parameters { + + if param.Rename != "original" { + t.Errorf("expected the parameter 'original' not to be renamed to '%s'", param.Rename) + t.FailNow() + } + } + +} func TestOptionalParam(t *testing.T) { reader := strings.NewReader(`{ "GET": {