feat: initial copy of v0.1.0
This commit is contained in:
parent
4cc801a7f3
commit
7d4cbb6b08
538 changed files with 63361 additions and 55213 deletions
|
|
@ -0,0 +1,135 @@
|
|||
package sqlserverFlexBetaFlavor
|
||||
|
||||
// import (
|
||||
// "context"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
//
|
||||
// "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3beta1api"
|
||||
//)
|
||||
//
|
||||
// type mockRequest struct {
|
||||
// executeFunc func() (*v3beta1api.GetFlavorsResponse, error)
|
||||
//}
|
||||
//
|
||||
// func (m *mockRequest) Page(_ int64) v3beta1api.ApiGetFlavorsRequestRequest { return m }
|
||||
// func (m *mockRequest) Size(_ int64) v3beta1api.ApiGetFlavorsRequestRequest { return m }
|
||||
// func (m *mockRequest) Sort(_ v3beta1api.FlavorSort) v3beta1api.ApiGetFlavorsRequestRequest {
|
||||
// return m
|
||||
//}
|
||||
// func (m *mockRequest) Execute() (*v3beta1api.GetFlavorsResponse, error) {
|
||||
// return m.executeFunc()
|
||||
//}
|
||||
//
|
||||
// type mockFlavorsClient struct {
|
||||
// executeRequest func() v3beta1api.ApiGetFlavorsRequestRequest
|
||||
//}
|
||||
//
|
||||
// func (m *mockFlavorsClient) GetFlavorsRequest(_ context.Context, _, _ string) v3beta1api.ApiGetFlavorsRequestRequest {
|
||||
// return m.executeRequest()
|
||||
//}
|
||||
//
|
||||
// var mockResp = func(page int64) (*v3beta1api.GetFlavorsResponse, error) {
|
||||
// if page == 1 {
|
||||
// return &v3beta1api.GetFlavorsResponse{
|
||||
// Flavors: &[]v3beta1api.ListFlavors{
|
||||
// {Id: utils.Ptr("flavor-1"), Description: utils.Ptr("first")},
|
||||
// {Id: utils.Ptr("flavor-2"), Description: utils.Ptr("second")},
|
||||
// },
|
||||
// }, nil
|
||||
// }
|
||||
// if page == 2 {
|
||||
// return &v3beta1api.GetFlavorsResponse{
|
||||
// Flavors: &[]v3beta1api.ListFlavors{
|
||||
// {Id: utils.Ptr("flavor-3"), Description: utils.Ptr("three")},
|
||||
// },
|
||||
// }, nil
|
||||
// }
|
||||
//
|
||||
// return &v3beta1api.GetFlavorsResponse{
|
||||
// Flavors: &[]v3beta1api.ListFlavors{},
|
||||
// }, nil
|
||||
//}
|
||||
//
|
||||
// func TestGetFlavorsByFilter(t *testing.T) {
|
||||
// tests := []struct {
|
||||
// description string
|
||||
// projectId string
|
||||
// region string
|
||||
// mockErr error
|
||||
// filter func(v3beta1api.ListFlavors) bool
|
||||
// wantCount int
|
||||
// wantErr bool
|
||||
// }{
|
||||
// {
|
||||
// description: "Success - Get all flavors (2 pages)",
|
||||
// projectId: "pid", region: "reg",
|
||||
// filter: func(_ v3beta1api.ListFlavors) bool { return true },
|
||||
// wantCount: 3,
|
||||
// wantErr: false,
|
||||
// },
|
||||
// {
|
||||
// description: "Success - Filter flavors by description",
|
||||
// projectId: "pid", region: "reg",
|
||||
// filter: func(f v3beta1api.ListFlavors) bool { return *f.Description == "first" },
|
||||
// wantCount: 1,
|
||||
// wantErr: false,
|
||||
// },
|
||||
// {
|
||||
// description: "Error - Missing parameters",
|
||||
// projectId: "", region: "reg",
|
||||
// wantErr: true,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// for _, tt := range tests {
|
||||
// t.Run(
|
||||
// tt.description, func(t *testing.T) {
|
||||
// var currentPage int64
|
||||
// client := &mockFlavorsClient{
|
||||
// executeRequest: func() v3beta1api.ApiGetFlavorsRequestRequest {
|
||||
// return &mockRequest{
|
||||
// executeFunc: func() (*v3beta1api.GetFlavorsResponse, error) {
|
||||
// currentPage++
|
||||
// return mockResp(currentPage)
|
||||
// },
|
||||
// }
|
||||
// },
|
||||
// }
|
||||
// actual, err := getFlavorsByFilter(context.Background(), client, tt.projectId, tt.region, tt.filter)
|
||||
//
|
||||
// if (err != nil) != tt.wantErr {
|
||||
// t.Errorf("getFlavorsByFilter() error = %v, wantErr %v", err, tt.wantErr)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if !tt.wantErr && len(actual) != tt.wantCount {
|
||||
// t.Errorf("getFlavorsByFilter() got %d flavors, want %d", len(actual), tt.wantCount)
|
||||
// }
|
||||
// },
|
||||
// )
|
||||
// }
|
||||
//}
|
||||
//
|
||||
// func TestGetAllFlavors(t *testing.T) {
|
||||
// var currentPage int64
|
||||
// client := &mockFlavorsClient{
|
||||
// executeRequest: func() v3beta1api.ApiGetFlavorsRequestRequest {
|
||||
// return &mockRequest{
|
||||
// executeFunc: func() (*v3beta1api.GetFlavorsResponse, error) {
|
||||
// currentPage++
|
||||
// return mockResp(currentPage)
|
||||
// },
|
||||
// }
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// res, err := getAllFlavors(context.Background(), client, "pid", "reg")
|
||||
// if err != nil {
|
||||
// t.Errorf("getAllFlavors() unexpected error: %v", err)
|
||||
// }
|
||||
// if len(res) != 3 {
|
||||
// t.Errorf("getAllFlavors() expected 3 flavor, got %d", len(res))
|
||||
// }
|
||||
//}
|
||||
Loading…
Add table
Add a link
Reference in a new issue