Skip to content

Commit a0f96d7

Browse files
committed
chore(sfs): update tests
1 parent 2a8a4c7 commit a0f96d7

File tree

7 files changed

+83
-83
lines changed

7 files changed

+83
-83
lines changed

stackit/internal/services/sfs/export-policy/resource_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func fixtureRulesModel() basetypes.ListValue {
4646
types.StringValue("172.16.0.0/24"),
4747
types.StringValue("172.16.0.251/32"),
4848
}),
49-
"order": types.Int64Value(0),
49+
"order": types.Int32Value(0),
5050
"read_only": types.BoolValue(false),
5151
"set_uuid": types.BoolValue(false),
5252
"super_user": types.BoolValue(false),
@@ -57,7 +57,7 @@ func fixtureRulesModel() basetypes.ListValue {
5757
types.StringValue("172.32.0.0/24"),
5858
types.StringValue("172.32.0.251/32"),
5959
}),
60-
"order": types.Int64Value(1),
60+
"order": types.Int32Value(1),
6161
"read_only": types.BoolValue(false),
6262
"set_uuid": types.BoolValue(false),
6363
"super_user": types.BoolValue(false),
@@ -152,7 +152,7 @@ func fixtureRulesPayloadModel() []rulesModel {
152152

153153
func fixtureExportPolicyCreatePayload(rules *[]sfs.CreateShareExportPolicyRequestRule) *sfs.CreateShareExportPolicyPayload {
154154
return &sfs.CreateShareExportPolicyPayload{
155-
Name: *new("createPayloadName"),
155+
Name: "createPayloadName",
156156
Rules: *rules,
157157
}
158158
}

stackit/internal/services/sfs/resourcepool/datasource_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestMapDatasourceFields(t *testing.T) {
2020
name string
2121
state *dataSourceModel
2222
region string
23-
input *sfs.GetResourcePoolResponseResourcePool
23+
input *sfs.ResourcePool
2424
expected *dataSourceModel
2525
isValid bool
2626
}{
@@ -31,7 +31,7 @@ func TestMapDatasourceFields(t *testing.T) {
3131
ProjectId: testProjectId,
3232
},
3333
"eu01",
34-
&sfs.GetResourcePoolResponseResourcePool{
34+
&sfs.ResourcePool{
3535
Id: testResourcePoolId.ValueStringPointer(),
3636
},
3737
&dataSourceModel{
@@ -42,7 +42,7 @@ func TestMapDatasourceFields(t *testing.T) {
4242
IpAcl: types.ListNull(types.StringType),
4343
Name: types.StringNull(),
4444
PerformanceClass: types.StringNull(),
45-
SizeGigabytes: types.Int64Null(),
45+
SizeGigabytes: types.Int32Null(),
4646
Region: testRegion,
4747
SizeReducibleAt: types.StringNull(),
4848
PerformanceClassDowngradableAt: types.StringNull(),
@@ -56,23 +56,23 @@ func TestMapDatasourceFields(t *testing.T) {
5656
ProjectId: testProjectId,
5757
},
5858
region: "eu01",
59-
input: &sfs.GetResourcePoolResponseResourcePool{
59+
input: &sfs.ResourcePool{
6060
AvailabilityZone: testAvailabilityZone.ValueStringPointer(),
61-
CountShares: utils.Ptr[int64](42),
61+
CountShares: utils.Ptr[int32](42),
6262
CreatedAt: &now,
6363
Id: testResourcePoolId.ValueStringPointer(),
64-
IpAcl: &[]string{"foo", "bar", "baz"},
64+
IpAcl: []string{"foo", "bar", "baz"},
6565
MountPath: new("mountpoint"),
6666
Name: new("testname"),
6767
PerformanceClass: &sfs.ResourcePoolPerformanceClass{
6868
Name: new("performance"),
69-
PeakIops: utils.Ptr[int64](42),
70-
Throughput: utils.Ptr[int64](54),
69+
PeakIops: utils.Ptr[int32](42),
70+
Throughput: utils.Ptr[int32](54),
7171
},
7272
PerformanceClassDowngradableAt: new(now),
7373
SizeReducibleAt: new(now.Add(1 * time.Hour)),
7474
Space: &sfs.ResourcePoolSpace{
75-
SizeGigabytes: utils.Ptr[int64](42),
75+
SizeGigabytes: utils.Ptr[int32](42),
7676
},
7777
State: new("state"),
7878
},
@@ -88,7 +88,7 @@ func TestMapDatasourceFields(t *testing.T) {
8888
}),
8989
Name: types.StringValue("testname"),
9090
PerformanceClass: types.StringValue("performance"),
91-
SizeGigabytes: types.Int64Value(42),
91+
SizeGigabytes: types.Int32Value(42),
9292
Region: testRegion,
9393
SizeReducibleAt: testTimePlus1h,
9494
PerformanceClassDowngradableAt: testTime,

stackit/internal/services/sfs/resourcepool/resource_test.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestMapFields(t *testing.T) {
3030
name string
3131
state *Model
3232
region string
33-
input *sfs.GetResourcePoolResponseResourcePool
33+
input *sfs.ResourcePool
3434
expected *Model
3535
isValid bool
3636
}{
@@ -41,7 +41,7 @@ func TestMapFields(t *testing.T) {
4141
ProjectId: testProjectId,
4242
},
4343
testRegion.ValueString(),
44-
&sfs.GetResourcePoolResponseResourcePool{
44+
&sfs.ResourcePool{
4545
Id: testResourcePoolId.ValueStringPointer(),
4646
},
4747
&Model{
@@ -52,7 +52,7 @@ func TestMapFields(t *testing.T) {
5252
IpAcl: types.ListNull(types.StringType),
5353
Name: types.StringNull(),
5454
PerformanceClass: types.StringNull(),
55-
SizeGigabytes: types.Int64Null(),
55+
SizeGigabytes: types.Int32Null(),
5656
Region: testRegion,
5757
},
5858
true,
@@ -64,23 +64,23 @@ func TestMapFields(t *testing.T) {
6464
ProjectId: testProjectId,
6565
},
6666
region: testRegion.ValueString(),
67-
input: &sfs.GetResourcePoolResponseResourcePool{
67+
input: &sfs.ResourcePool{
6868
AvailabilityZone: testAvailabilityZone.ValueStringPointer(),
69-
CountShares: utils.Ptr[int64](42),
69+
CountShares: utils.Ptr[int32](42),
7070
CreatedAt: &testTime,
7171
Id: testResourcePoolId.ValueStringPointer(),
72-
IpAcl: &[]string{"foo", "bar", "baz"},
72+
IpAcl: []string{"foo", "bar", "baz"},
7373
MountPath: new("mountpoint"),
7474
Name: new("testname"),
7575
PerformanceClass: &sfs.ResourcePoolPerformanceClass{
7676
Name: new("performance"),
77-
PeakIops: utils.Ptr[int64](42),
78-
Throughput: utils.Ptr[int64](54),
77+
PeakIops: utils.Ptr[int32](42),
78+
Throughput: utils.Ptr[int32](54),
7979
},
8080
PerformanceClassDowngradableAt: &testTime,
8181
SizeReducibleAt: &testTime,
8282
Space: &sfs.ResourcePoolSpace{
83-
SizeGigabytes: utils.Ptr[int64](42),
83+
SizeGigabytes: utils.Ptr[int32](42),
8484
},
8585
State: new("state"),
8686
},
@@ -96,7 +96,7 @@ func TestMapFields(t *testing.T) {
9696
}),
9797
Name: types.StringValue("testname"),
9898
PerformanceClass: types.StringValue("performance"),
99-
SizeGigabytes: types.Int64Value(42),
99+
SizeGigabytes: types.Int32Value(42),
100100
Region: testRegion,
101101
},
102102
isValid: true,
@@ -134,14 +134,14 @@ func TestToCreatePayload(t *testing.T) {
134134
IpAcl: testIpAcl,
135135
Name: types.StringValue("testname"),
136136
PerformanceClass: types.StringValue("performance"),
137-
SizeGigabytes: types.Int64Value(42),
137+
SizeGigabytes: types.Int32Value(42),
138138
},
139139
&sfs.CreateResourcePoolPayload{
140-
AvailabilityZone: testAvailabilityZone.ValueStringPointer(),
141-
IpAcl: new([]string{"foo", "bar", "baz"}),
142-
Name: new("testname"),
143-
PerformanceClass: new("performance"),
144-
SizeGigabytes: utils.Ptr[int64](42),
140+
AvailabilityZone: testAvailabilityZone.ValueString(),
141+
IpAcl: []string{"foo", "bar", "baz"},
142+
Name: "testname",
143+
PerformanceClass: "performance",
144+
SizeGigabytes: 42,
145145
},
146146
false,
147147
},
@@ -155,14 +155,14 @@ func TestToCreatePayload(t *testing.T) {
155155
IpAcl: types.ListNull(types.StringType),
156156
Name: types.StringValue("testname"),
157157
PerformanceClass: types.StringValue("performance"),
158-
SizeGigabytes: types.Int64Value(42),
158+
SizeGigabytes: types.Int32Value(42),
159159
},
160160
&sfs.CreateResourcePoolPayload{
161-
AvailabilityZone: testAvailabilityZone.ValueStringPointer(),
161+
AvailabilityZone: testAvailabilityZone.ValueString(),
162162
IpAcl: nil,
163-
Name: new("testname"),
164-
PerformanceClass: new("performance"),
165-
SizeGigabytes: utils.Ptr[int64](42),
163+
Name: "testname",
164+
PerformanceClass: "performance",
165+
SizeGigabytes: 42,
166166
},
167167
false,
168168
},
@@ -198,13 +198,13 @@ func TestToUpdatePayload(t *testing.T) {
198198
IpAcl: testIpAcl,
199199
Name: types.StringValue("testname"),
200200
PerformanceClass: types.StringValue("performance"),
201-
SizeGigabytes: types.Int64Value(42),
201+
SizeGigabytes: types.Int32Value(42),
202202
SnapshotsAreVisible: types.BoolValue(true),
203203
},
204204
&sfs.UpdateResourcePoolPayload{
205-
IpAcl: new([]string{"foo", "bar", "baz"}),
205+
IpAcl: []string{"foo", "bar", "baz"},
206206
PerformanceClass: new("performance"),
207-
SizeGigabytes: utils.Ptr[int64](42),
207+
SizeGigabytes: *sfs.NewNullableInt32(utils.Ptr[int32](42)),
208208
SnapshotsAreVisible: new(true),
209209
},
210210
false,
@@ -219,12 +219,12 @@ func TestToUpdatePayload(t *testing.T) {
219219
IpAcl: types.ListNull(types.StringType),
220220
Name: types.StringValue("testname"),
221221
PerformanceClass: types.StringValue("performance"),
222-
SizeGigabytes: types.Int64Value(42),
222+
SizeGigabytes: types.Int32Value(42),
223223
},
224224
&sfs.UpdateResourcePoolPayload{
225225
IpAcl: nil,
226226
PerformanceClass: new("performance"),
227-
SizeGigabytes: utils.Ptr[int64](42),
227+
SizeGigabytes: *sfs.NewNullableInt32(utils.Ptr[int32](42)),
228228
},
229229
false,
230230
},
@@ -238,12 +238,12 @@ func TestToUpdatePayload(t *testing.T) {
238238
IpAcl: types.ListValueMust(types.StringType, []attr.Value{}),
239239
Name: types.StringValue("testname"),
240240
PerformanceClass: types.StringValue("performance"),
241-
SizeGigabytes: types.Int64Value(42),
241+
SizeGigabytes: types.Int32Value(42),
242242
},
243243
&sfs.UpdateResourcePoolPayload{
244-
IpAcl: new([]string{}),
244+
IpAcl: []string{},
245245
PerformanceClass: new("performance"),
246-
SizeGigabytes: utils.Ptr[int64](42),
246+
SizeGigabytes: *sfs.NewNullableInt32(utils.Ptr[int32](42)),
247247
},
248248
false,
249249
},

stackit/internal/services/sfs/sfs_acc_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1212
"github.com/hashicorp/terraform-plugin-testing/terraform"
1313
"github.com/stackitcloud/stackit-sdk-go/core/utils"
14-
"github.com/stackitcloud/stackit-sdk-go/services/sfs"
14+
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"
1515

1616
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
1717
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/testutil"
@@ -456,17 +456,17 @@ func testAccExportPolicyDestroy(s *terraform.State) error {
456456
policyToDestroy = append(policyToDestroy, policyId)
457457
}
458458

459-
policiesResp, err := client.ListShareExportPoliciesExecute(ctx, testutil.ProjectId, exportPolicyResource["region"])
459+
policiesResp, err := client.DefaultAPI.ListShareExportPolicies(ctx, testutil.ProjectId, exportPolicyResource["region"]).Execute()
460460
if err != nil {
461461
return fmt.Errorf("getting policiesResp: %w", err)
462462
}
463463

464464
// iterate over policiesResp
465-
policies := *policiesResp.ShareExportPolicies
465+
policies := policiesResp.ShareExportPolicies
466466
for i := range policies {
467467
id := *policies[i].Id
468468
if utils.Contains(policyToDestroy, id) {
469-
_, err := client.DeleteShareExportPolicy(ctx, testutil.ProjectId, exportPolicyResource["region"], id).Execute()
469+
_, err := client.DefaultAPI.DeleteShareExportPolicy(ctx, testutil.ProjectId, exportPolicyResource["region"], id).Execute()
470470
if err != nil {
471471
return fmt.Errorf("deleting policy %s during CheckDestroy: %w", *policies[i].Id, err)
472472
}
@@ -493,7 +493,7 @@ func testAccResourcePoolDestroyed(s *terraform.State) error {
493493
}
494494

495495
region := testutil.Region
496-
resourcePoolsResp, err := client.ListResourcePoolsExecute(ctx, testutil.ProjectId, region)
496+
resourcePoolsResp, err := client.DefaultAPI.ListResourcePools(ctx, testutil.ProjectId, region).Execute()
497497
if err != nil {
498498
return fmt.Errorf("getting resource pools: %w", err)
499499
}
@@ -503,20 +503,20 @@ func testAccResourcePoolDestroyed(s *terraform.State) error {
503503
id := pool.Id
504504

505505
if utils.Contains(resourcePoolsToDestroy, *id) {
506-
shares, err := client.ListSharesExecute(ctx, testutil.ProjectId, region, *id)
506+
shares, err := client.DefaultAPI.ListShares(ctx, testutil.ProjectId, region, *id).Execute()
507507
if err != nil {
508508
return fmt.Errorf("cannot list shares: %w", err)
509509
}
510510
if shares.Shares != nil {
511-
for _, share := range *shares.Shares {
512-
_, err := client.DeleteShareExecute(ctx, testutil.ProjectId, region, *id, *share.Id)
511+
for _, share := range shares.Shares {
512+
_, err := client.DefaultAPI.DeleteShare(ctx, testutil.ProjectId, region, *id, *share.Id).Execute()
513513
if err != nil {
514514
return fmt.Errorf("cannot delete share %q in pool %q: %w", *share.Id, *id, err)
515515
}
516516
}
517517
}
518518

519-
_, err = client.DeleteResourcePool(ctx, testutil.ProjectId, region, *id).
519+
_, err = client.DefaultAPI.DeleteResourcePool(ctx, testutil.ProjectId, region, *id).
520520
Execute()
521521
if err != nil {
522522
return fmt.Errorf("deleting resourcepool %s during CheckDestroy: %w", *pool.Id, err)

stackit/internal/services/sfs/share/datasource_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestMapDatasourceFields(t *testing.T) {
1515
name string
1616
state *dataSourceModel
1717
region string
18-
input *sfs.GetShareResponseShare
18+
input *sfs.Share
1919
expected *dataSourceModel
2020
isValid bool
2121
}{
@@ -27,15 +27,15 @@ func TestMapDatasourceFields(t *testing.T) {
2727
ResourcePoolId: testResourcePoolId,
2828
},
2929
"eu01",
30-
&sfs.GetShareResponseShare{
31-
ExportPolicy: sfs.NewNullableShareExportPolicy(&sfs.ShareExportPolicy{
30+
&sfs.Share{
31+
ExportPolicy: *sfs.NewNullableShareExportPolicy(&sfs.ShareExportPolicy{
3232
Id: testId.ValueStringPointer(),
3333
Name: new("test-policy"),
3434
}),
3535
Id: testShareId.ValueStringPointer(),
3636
MountPath: new("/testmount"),
3737
Name: new("test-name"),
38-
SpaceHardLimitGigabytes: utils.Ptr[int64](42),
38+
SpaceHardLimitGigabytes: utils.Ptr[int32](42),
3939
},
4040
&dataSourceModel{
4141
Id: testId,
@@ -44,7 +44,7 @@ func TestMapDatasourceFields(t *testing.T) {
4444
ShareId: testShareId,
4545
Name: types.StringValue("test-name"),
4646
ExportPolicyName: testPolicyName,
47-
SpaceHardLimitGigabytes: types.Int64Value(42),
47+
SpaceHardLimitGigabytes: types.Int32Value(42),
4848
MountPath: types.StringValue("/testmount"),
4949
Region: testRegion,
5050
},

0 commit comments

Comments
 (0)