fix: linter errors
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
CI Workflow / Prepare GO cache (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled
CI Workflow / Code coverage report (pull_request) Has been cancelled
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
CI Workflow / Prepare GO cache (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled
CI Workflow / Code coverage report (pull_request) Has been cancelled
This commit is contained in:
parent
53f4e4bd49
commit
3182aa29b6
5 changed files with 144 additions and 136 deletions
7
.github/workflows/ci.yaml
vendored
7
.github/workflows/ci.yaml
vendored
|
|
@ -305,6 +305,13 @@ jobs:
|
||||||
actions: read # to download code coverage results from "main" job
|
actions: read # to download code coverage results from "main" job
|
||||||
pull-requests: write # write permission needed to comment on PR
|
pull-requests: write # write permission needed to comment on PR
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install needed tools
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
apt-get -y -qq update
|
||||||
|
apt-get -y -qq install sudo
|
||||||
|
|
||||||
- name: Check new code coverage
|
- name: Check new code coverage
|
||||||
uses: fgrosse/go-coverage-report@v1.2.0
|
uses: fgrosse/go-coverage-report@v1.2.0
|
||||||
continue-on-error: true # Add this line to prevent pipeline failures in forks
|
continue-on-error: true # Add this line to prevent pipeline failures in forks
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package postgresFlexAlphaFlavor
|
package postgresflexalphaflavor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package postgresFlexAlphaFlavor
|
package postgresflexalphaflavor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
||||||
|
|
@ -1,134 +1,135 @@
|
||||||
package postgresFlexAlphaFlavor
|
package postgresflexalphaflavor
|
||||||
|
|
||||||
//
|
/*
|
||||||
// import (
|
import (
|
||||||
// "context"
|
"context"
|
||||||
// "testing"
|
"testing"
|
||||||
//
|
|
||||||
// postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
||||||
//)
|
)
|
||||||
//
|
|
||||||
// type mockRequest struct {
|
type mockRequest struct {
|
||||||
// executeFunc func() (*postgresflex.GetFlavorsResponse, error)
|
executeFunc func() (*postgresflex.GetFlavorsResponse, error)
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
// func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
func (m *mockRequest) Page(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
||||||
// func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
func (m *mockRequest) Size(_ int32) postgresflex.ApiGetFlavorsRequestRequest { return m }
|
||||||
// func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest {
|
func (m *mockRequest) Sort(_ postgresflex.FlavorSort) postgresflex.ApiGetFlavorsRequestRequest {
|
||||||
// return m
|
return m
|
||||||
//}
|
}
|
||||||
// func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) {
|
func (m *mockRequest) Execute() (*postgresflex.GetFlavorsResponse, error) {
|
||||||
// return m.executeFunc()
|
return m.executeFunc()
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
// type mockFlavorsClient struct {
|
type mockFlavorsClient struct {
|
||||||
// executeRequest func() postgresflex.ApiGetFlavorsRequestRequest
|
executeRequest func() postgresflex.ApiGetFlavorsRequestRequest
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
// func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest {
|
func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) postgresflex.ApiGetFlavorsRequestRequest {
|
||||||
// return m.executeRequest()
|
return m.executeRequest()
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
// var mockResp = func(page int32) (*postgresflex.GetFlavorsResponse, error) {
|
var mockResp = func(page int32) (*postgresflex.GetFlavorsResponse, error) {
|
||||||
// if page == 1 {
|
if page == 1 {
|
||||||
// return &postgresflex.GetFlavorsResponse{
|
return &postgresflex.GetFlavorsResponse{
|
||||||
// Flavors: []postgresflex.ListFlavors{
|
Flavors: []postgresflex.ListFlavors{
|
||||||
// {Id: "flavor-1", Description: "first"},
|
{Id: "flavor-1", Description: "first"},
|
||||||
// {Id: "flavor-2", Description: "second"},
|
{Id: "flavor-2", Description: "second"},
|
||||||
// },
|
},
|
||||||
// }, nil
|
}, nil
|
||||||
// }
|
}
|
||||||
// if page == 2 {
|
if page == 2 {
|
||||||
// return &postgresflex.GetFlavorsResponse{
|
return &postgresflex.GetFlavorsResponse{
|
||||||
// Flavors: []postgresflex.ListFlavors{
|
Flavors: []postgresflex.ListFlavors{
|
||||||
// {Id: "flavor-3", Description: "three"},
|
{Id: "flavor-3", Description: "three"},
|
||||||
// },
|
},
|
||||||
// }, nil
|
}, nil
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return &postgresflex.GetFlavorsResponse{
|
return &postgresflex.GetFlavorsResponse{
|
||||||
// Flavors: []postgresflex.ListFlavors{},
|
Flavors: []postgresflex.ListFlavors{},
|
||||||
// }, nil
|
}, nil
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
// func TestGetFlavorsByFilter(t *testing.T) {
|
func TestGetFlavorsByFilter(t *testing.T) {
|
||||||
// tests := []struct {
|
tests := []struct {
|
||||||
// description string
|
description string
|
||||||
// projectId string
|
projectId string
|
||||||
// region string
|
region string
|
||||||
// mockErr error
|
mockErr error
|
||||||
// filter func(postgresflex.ListFlavors) bool
|
filter func(postgresflex.ListFlavors) bool
|
||||||
// wantCount int
|
wantCount int
|
||||||
// wantErr bool
|
wantErr bool
|
||||||
// }{
|
}{
|
||||||
// {
|
{
|
||||||
// description: "Success - Get all flavors (2 pages)",
|
description: "Success - Get all flavors (2 pages)",
|
||||||
// projectId: "pid", region: "reg",
|
projectId: "pid", region: "reg",
|
||||||
// filter: func(_ postgresflex.ListFlavors) bool { return true },
|
filter: func(_ postgresflex.ListFlavors) bool { return true },
|
||||||
// wantCount: 3,
|
wantCount: 3,
|
||||||
// wantErr: false,
|
wantErr: false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// description: "Success - Filter flavors by description",
|
description: "Success - Filter flavors by description",
|
||||||
// projectId: "pid", region: "reg",
|
projectId: "pid", region: "reg",
|
||||||
// filter: func(f postgresflex.ListFlavors) bool { return f.Description == "first" },
|
filter: func(f postgresflex.ListFlavors) bool { return f.Description == "first" },
|
||||||
// wantCount: 1,
|
wantCount: 1,
|
||||||
// wantErr: false,
|
wantErr: false,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// description: "Error - Missing parameters",
|
description: "Error - Missing parameters",
|
||||||
// projectId: "", region: "reg",
|
projectId: "", region: "reg",
|
||||||
// wantErr: true,
|
wantErr: true,
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
// t.Run(
|
t.Run(
|
||||||
// tt.description, func(t *testing.T) {
|
tt.description, func(t *testing.T) {
|
||||||
// var currentPage int32
|
var currentPage int32
|
||||||
// client := &mockFlavorsClient{
|
client := &mockFlavorsClient{
|
||||||
// executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest {
|
executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest {
|
||||||
// return mockRequest{
|
return mockRequest{
|
||||||
// executeFunc: func() (*postgresflex.GetFlavorsResponse, error) {
|
executeFunc: func() (*postgresflex.GetFlavorsResponse, error) {
|
||||||
// currentPage++
|
currentPage++
|
||||||
// return mockResp(currentPage)
|
return mockResp(currentPage)
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter)
|
actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter)
|
||||||
//
|
|
||||||
// if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
// t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if !tt.wantErr && len(actual) != tt.wantCount {
|
if !tt.wantErr && len(actual) != tt.wantCount {
|
||||||
// t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount)
|
t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount)
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//func TestGetAllFlavors(t *testing.T) {
|
func TestGetAllFlavors(t *testing.T) {
|
||||||
// var currentPage int32
|
var currentPage int32
|
||||||
// client := &mockFlavorsClient{
|
client := &mockFlavorsClient{
|
||||||
// executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest {
|
executeRequest: func() postgresflex.ApiGetFlavorsRequestRequest {
|
||||||
// return mockRequest{
|
return mockRequest{
|
||||||
// executeFunc: func() (*postgresflex.GetFlavorsResponse, error) {
|
executeFunc: func() (*postgresflex.GetFlavorsResponse, error) {
|
||||||
// currentPage++
|
currentPage++
|
||||||
// return mockResp(currentPage)
|
return mockResp(currentPage)
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// res, err := getAllFlavors(context.Background(), client, "pid", "reg")
|
res, err := getAllFlavors(context.Background(), client, "pid", "reg")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Errorf("getAllFlavors() unexpected error: %v", err)
|
t.Errorf("getAllFlavors() unexpected error: %v", err)
|
||||||
// }
|
}
|
||||||
// if len(res) != 3 {
|
if len(res) != 3 {
|
||||||
// t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res))
|
t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res))
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue