Skip to content

Commit 432482e

Browse files
refactor(scf): implement PR feedback
1 parent 500d923 commit 432482e

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎internal/cmd/beta/scf/platform/list/list.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6060
}
6161

6262
// Call API
63-
resp, err := buildRequest(ctx, model, apiClient.DefaultAPI, 1, maxPageSize).Execute()
63+
resp, err := buildRequest(ctx, model, apiClient.DefaultAPI).Execute()
6464
if err != nil {
6565
return fmt.Errorf("fetch STACKIT Cloud Foundry platforms: %w", err)
6666
}
@@ -108,13 +108,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
108108
return &model, nil
109109
}
110110

111-
func buildRequest(ctx context.Context, model *inputModel, apiClient scf.DefaultAPI, page, perPage int64) scf.ApiListPlatformsRequest {
111+
func buildRequest(ctx context.Context, model *inputModel, apiClient scf.DefaultAPI) scf.ApiListPlatformsRequest {
112112
// the API has non AIP-compliant pagination, which cannot be adapted with out SDK pagination utils.
113-
pageSize := int64(perPage)
113+
pageSize := int64(maxPageSize)
114114
if model.Limit != nil && *model.Limit < pageSize {
115115
pageSize = *model.Limit
116116
}
117-
return apiClient.ListPlatforms(ctx, model.ProjectId, model.Region).Page(page).PerPage(pageSize)
117+
return apiClient.ListPlatforms(ctx, model.ProjectId, model.Region).Page(1).PerPage(pageSize)
118118
}
119119

120120
func outputResult(p *print.Printer, outputFormat, projectLabel string, resp *scf.PlatformList) error {

‎internal/cmd/beta/scf/platform/list/list_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ func TestBuildRequest(t *testing.T) {
138138
}),
139139
isValid: true,
140140
expectedRequest: fixtureRequest(func(request *scf.ApiListPlatformsRequest) {
141-
request.PerPage(maxPageSize)
141+
*request = request.PerPage(maxPageSize)
142142
}),
143143
},
144144
}
145145
for _, tt := range tests {
146146
t.Run(tt.description, func(t *testing.T) {
147-
request := buildRequest(testCtx, tt.model, testClient.DefaultAPI, 1, testLimit)
147+
request := buildRequest(testCtx, tt.model, testClient.DefaultAPI)
148148

149149
diff := cmp.Diff(request, tt.expectedRequest,
150150
cmp.AllowUnexported(tt.expectedRequest, scf.DefaultAPIService{}),

‎internal/cmd/beta/scf/platform/quota/list/list_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func TestOutputResult(t *testing.T) {
184184
params := testparams.NewTestParams()
185185
for _, tt := range tests {
186186
t.Run(tt.name, func(t *testing.T) {
187+
tt.model.OutputFormat = tt.outputFormat
187188
if err := outputResult(params.Printer, tt.model, tt.quotas); (err != nil) != tt.wantErr {
188189
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
189190
}

0 commit comments

Comments
 (0)