go.api_test.mustache Maven / Gradle / Ivy
/*
{{#appName}}
{{{.}}}
{{/appName}}
Testing {{classname}}Service
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
package {{packageName}}
import (
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
{{goImportAlias}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}"
)
func Test_{{packageName}}_{{classname}}Service(t *testing.T) {
configuration := {{goImportAlias}}.NewConfiguration()
apiClient := {{goImportAlias}}.NewAPIClient(configuration)
{{#operations}}
{{#operation}}
t.Run("Test {{classname}}Service {{{nickname}}}", func(t *testing.T) {
{{^pathParams}}
t.Skip("skip test") // remove to run test
{{/pathParams}}
{{#pathParams}}
{{#-first}}
t.Skip("skip test") // remove to run test
{{/-first}}
var {{paramName}} {{{dataType}}}
{{/pathParams}}
{{#returnType}}resp, {{/returnType}}httpRes, err := apiClient.{{classname}}.{{operationId}}(context.Background(){{#pathParams}}, {{paramName}}{{/pathParams}}).Execute()
require.Nil(t, err)
{{#returnType}}
require.NotNil(t, resp)
{{/returnType}}
assert.Equal(t, 200, httpRes.StatusCode)
})
{{/operation}}
{{/operations}}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy