Skip to content

Commit 60997c6

Browse files
committed
add delete scf org waiter
1 parent 659e317 commit 60997c6

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
## Release (2025-XX-XX)
22
- `scf`:
3-
- [v0.2.0](services/scf/CHANGELOG.md#v020)
4-
- **Feature:** Add field `OrgId` in model `OrgManager`
5-
- **Feature:** Add new model `OrganizationCreateBffResponse` and `SpaceCreatedBffResponse`
3+
- [v0.2.1](services/scf/CHANGELOG.md#v021)
4+
- **Feature:** Add waiter for deletion of organization
5+
- [v0.2.0](services/scf/CHANGELOG.md#v020)
6+
- **Feature:** Add field `OrgId` in model `OrgManager`
7+
- **Feature:** Add new model `OrganizationCreateBffResponse` and `SpaceCreatedBffResponse`
68
- [v0.1.0](services/scf/CHANGELOG.md#v010)
79
- **New:** STACKIT Cloud Foundry module
810
- `core`: [v0.17.3](core/CHANGELOG.md#v0173)

services/scf/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.2.1
2+
- **Feature:** Add waiter for deletion of organization
3+
14
## v0.2.0
25
- **Feature:** Add field `OrgId` in model `OrgManager`
36
- **Feature:** Add new model `OrganizationCreateBffResponse` and `SpaceCreatedBffResponse`

services/scf/wait/wait.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/stackitcloud/stackit-sdk-go/services/scf"
1313
)
1414

15-
const STATUS_DELETING_FAILED = "deleting_failed"
15+
const status_deleting_failed = "deleting_failed"
1616

1717
// Interfaces needed for tests
1818
type APIClientInterface interface {
@@ -31,7 +31,10 @@ func DeleteOrganizationWaitHandler(ctx context.Context, a APIClientInterface, pr
3131
}
3232
return false, s, err
3333
}
34-
if *s.Status == STATUS_DELETING_FAILED {
34+
if s == nil {
35+
return false, nil, errors.New("organization is nil")
36+
}
37+
if *s.Status == status_deleting_failed {
3538
return true, nil, fmt.Errorf("delete failed for Organization with id %s", orgId)
3639
}
3740
return false, s, nil

services/scf/wait/wait_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type apiClientMocked struct {
2222
returnInstance bool
2323
projectId string
2424
instanceId string
25-
getGitResponse *scf.Organization
25+
getSCFResponse *scf.Organization
2626
}
2727

2828
func (a *apiClientMocked) GetOrganizationExecute(_ context.Context, _, _, _ string) (*scf.Organization, error) {
@@ -34,7 +34,7 @@ func (a *apiClientMocked) GetOrganizationExecute(_ context.Context, _, _, _ stri
3434
if !a.returnInstance {
3535
return nil, nil
3636
}
37-
return a.getGitResponse, nil
37+
return a.getSCFResponse, nil
3838
}
3939

4040
func TestDeleteOrganizationWaitHandler(t *testing.T) {
@@ -67,6 +67,12 @@ func TestDeleteOrganizationWaitHandler(t *testing.T) {
6767
Status: &statusDeletingFailed,
6868
},
6969
},
70+
{
71+
desc: "Instance is nil",
72+
wantErr: true,
73+
returnInstance: true,
74+
getOrgResponse: nil,
75+
},
7076
}
7177
for _, tt := range tests {
7278
t.Run(tt.desc, func(t *testing.T) {
@@ -76,7 +82,7 @@ func TestDeleteOrganizationWaitHandler(t *testing.T) {
7682
getFails: tt.getFails,
7783
errorCode: tt.errorCode,
7884
returnInstance: tt.returnInstance,
79-
getGitResponse: tt.getOrgResponse,
85+
getSCFResponse: tt.getOrgResponse,
8086
}
8187

8288
handler := DeleteOrganizationWaitHandler(context.Background(), apiClient, apiClient.projectId, REGION, apiClient.instanceId)

0 commit comments

Comments
 (0)