Skip to content

Commit 4098401

Browse files
committed
chore(logs): refactor delete
1 parent 8ef4d89 commit 4098401

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

internal/cmd/logs/instance/delete/delete.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6666
projectLabel = model.ProjectId
6767
}
6868

69-
instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceID)
69+
instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceID)
7070
if err != nil {
7171
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
7272
instanceLabel = model.InstanceID
@@ -89,7 +89,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8989
// Wait for async operation, if async mode not enabled
9090
if !model.Async {
9191
err := spinner.Run(params.Printer, "Deleting instance", func() error {
92-
_, err = wait.DeleteLogsInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.InstanceID).WaitWithContext(ctx)
92+
_, err = wait.DeleteLogsInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceID).WaitWithContext(ctx)
9393
return err
9494
})
9595
if err != nil {
@@ -127,6 +127,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
127127
}
128128

129129
func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteLogsInstanceRequest {
130-
req := apiClient.DeleteLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID)
130+
req := apiClient.DefaultAPI.DeleteLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID)
131131
return req
132132
}

internal/cmd/logs/instance/delete/delete_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type testCtxKey struct{}
2121

2222
var (
2323
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
24-
testClient = &logs.APIClient{}
24+
testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}}
2525
testProjectId = uuid.NewString()
2626
testInstanceId = uuid.NewString()
2727
)
@@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6767

6868
// Request
6969
func fixtureRequest(mods ...func(request *logs.ApiDeleteLogsInstanceRequest)) logs.ApiDeleteLogsInstanceRequest {
70-
request := testClient.DeleteLogsInstance(testCtx, testProjectId, testRegion, testInstanceId)
70+
request := testClient.DefaultAPI.DeleteLogsInstance(testCtx, testProjectId, testRegion, testInstanceId)
7171
for _, mod := range mods {
7272
mod(&request)
7373
}
@@ -165,7 +165,7 @@ func TestBuildRequest(t *testing.T) {
165165

166166
diff := cmp.Diff(request, tt.expectedRequest,
167167
cmp.AllowUnexported(tt.expectedRequest),
168-
cmpopts.EquateComparable(testCtx),
168+
cmpopts.EquateComparable(testCtx, tt.expectedRequest),
169169
)
170170
if diff != "" {
171171
t.Fatalf("Data does not match: %s", diff)

0 commit comments

Comments
 (0)