From b5aee2ce516df0d4b91192f3e06ba55f8de4da3c Mon Sep 17 00:00:00 2001 From: mlosicki Date: Mon, 24 Jan 2022 01:01:54 +0100 Subject: [PATCH] improve test --- default_api_test.go | 53 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/default_api_test.go b/default_api_test.go index fc0af54..ba42205 100644 --- a/default_api_test.go +++ b/default_api_test.go @@ -2365,13 +2365,52 @@ func TestDefaultApiService_GetBranchesPagination(t *testing.T) { context.TODO(), NewConfiguration(ts.URL), ) - _, err := client.DefaultApi.GetBranches("PROJECT", "REPO", map[string]interface{}{ - "limit": 100, - "start": 0, - }) - if err != nil { - t.Errorf("DefaultApiService.GetBranches() error = %v", err) - return + type fields struct { + client *APIClient + } + type args struct { + project string + repository string + localVarOptionals map[string]interface{} + } + tests := []struct { + name string + fields fields + args args + want *APIResponse + wantErr, integrationTest bool + }{ + {"limitAndStartSet", fields{client: client}, args{ + project: "PROJECT", repository: "REPO", + localVarOptionals: map[string]interface{}{ + "limit": 100, + "start": 0, + }}, nil, false, false}, + {"incorrectLimit", fields{client: client}, args{ + project: "PROJECT", repository: "REPO", + localVarOptionals: map[string]interface{}{ + "limit": "wrong", + }}, nil, true, false}, + {"incorrectStart", fields{client: client}, args{ + project: "PROJECT", repository: "REPO", + localVarOptionals: map[string]interface{}{ + "start": "wrong", + }}, nil, true, false}, + } + for _, tt := range tests { + if tt.integrationTest != runIntegrationTests { + continue + } + t.Run(tt.name, func(t *testing.T) { + a := &DefaultApiService{ + client: tt.fields.client, + } + _, err := a.GetBranches(tt.args.project, tt.args.repository, tt.args.localVarOptionals) + if (err != nil) != tt.wantErr { + t.Errorf("DefaultApiService.GetBranches() error = %v, wantErr %v", err, tt.wantErr) + return + } + }) } }