From fc09ddcaaab334160984a239773faa0c14dd1abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Thu, 28 Nov 2024 08:52:12 +0000 Subject: [PATCH] fix: Fix unit test template to support different type path parameters (#112) --- templates/go/api_test.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/go/api_test.mustache b/templates/go/api_test.mustache index 3705694..317d1cb 100644 --- a/templates/go/api_test.mustache +++ b/templates/go/api_test.mustache @@ -28,7 +28,7 @@ func Test_{{packageName}}_{{classname}}Service(t *testing.T) { {{#operation}} t.Run("Test {{classname}}Service {{{nickname}}}", func(t *testing.T) { path := "{{{path}}}"{{#pathParams}} - {{paramName}}Value := {{#isString}}"{{paramName}}"{{/isString}}{{#isInteger}}int32(12345){{/isInteger}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}} + {{paramName}}Value := {{#isString}}"{{paramName}}"{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}} path = strings.Replace(path, "{"+"{{baseName}}"+"}", url.PathEscape(ParameterValueToString({{paramName}}Value, "{{paramName}}")), -1){{/pathParams}} test{{classname}}ServeMux := http.NewServeMux() @@ -79,7 +79,7 @@ func Test_{{packageName}}_{{classname}}Service(t *testing.T) { {{#allParams}} {{#required}} {{#isPathParam}} - {{paramName}} := {{#isString}}"{{paramName}}"{{/isString}}{{#isInteger}}int32(12345){{/isInteger}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}} + {{paramName}} := {{#isString}}"{{paramName}}"{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}} {{/isPathParam}} {{^isPathParam}} {{#isPrimitiveType}}