Skip to content

Commit ccb055f

Browse files
committed
fix(opensearch): acc tests
1 parent 1809485 commit ccb055f

File tree

6 files changed

+117
-286
lines changed

6 files changed

+117
-286
lines changed

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,8 @@ github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.26.1 h1:AO5Np67/w0
708708
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.26.1/go.mod h1:Reo2Nk3yiA686quUMrk0eKwzpzaAZ7KwmzHzScNdG8Q=
709709
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQx954yI8fuQmxXwRf/myqAdLg2KvxImp00g=
710710
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5/go.mod h1:xmAWk9eom8wznvLuLfm0F4xyeiBX8LaggXsKFmos+dw=
711-
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0 h1:/8lmviszgrB+0Cz7HdhFELyTiTeqIs7LfnI6sNX4rW8=
712-
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0/go.mod h1:hnhvlLX1Y71R8KIQqLBeoSZqkU5ZJOG0J4wz0LeUdaw=
713711
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.29.0 h1:I8NF8Q5nRj7/7qDI8Qm4oI0KCNQcOjE6kqyBdWcUoxk=
714712
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.29.0/go.mod h1:wk2Oz+7pxT9YF1h6elWzdlhU6V7GSQXcGixxlXxNe+U=
715-
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 h1:CXM9cZ9WeTyJd+Aw/hnJnDsKRVAQi4qgtd0RJ3zoPwo=
716-
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6/go.mod h1:KJNceOHRefjku1oVBoHG7idCS/SeW42WJ+55bN3AxrQ=
717713
github.com/stackitcloud/stackit-sdk-go/services/redis v0.27.3 h1:wZIGETPQ1aiJwzJMVjatdu/Kv+/yuKVOf5RaMWW9bpU=
718714
github.com/stackitcloud/stackit-sdk-go/services/redis v0.27.3/go.mod h1:jgWx29zvZP0R3tXAC/qWU5eBsPfLBJFP96mx9hwdFPM=
719715
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.20.0 h1:bT/qoghsdKvLomCay9Wj4Fu63lx0cD2zr23Fjqzgotc=

stackit/internal/conversion/conversion.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ func StringListToSlice(list basetypes.ListValue) ([]string, error) {
156156
return nil, nil
157157
}
158158

159-
var listStr []string
159+
// Instantiate an empty slice to ensure the slice is not nil
160+
listStr := []string{}
160161
for i, el := range list.Elements() {
161162
elStr, ok := el.(types.String)
162163
if !ok {

stackit/internal/conversion/conversion_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ func TestStringListToSlice(t *testing.T) {
469469
in: basetypes.NewListNull(types.StringType),
470470
want: nil,
471471
},
472+
{
473+
name: "empty list",
474+
in: basetypes.NewListValueMust(types.StringType, []attr.Value{}),
475+
want: []string{},
476+
},
472477
{
473478
name: "invalid type",
474479
in: basetypes.NewListValueMust(types.Int64Type, []attr.Value{types.Int64Value(123)}),

stackit/internal/services/opensearch/instance/resource_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,57 @@ func TestToUpdatePayload(t *testing.T) {
342342
},
343343
true,
344344
},
345+
{
346+
"plugins empty slice",
347+
&Model{
348+
PlanId: types.StringValue("plan"),
349+
Parameters: types.ObjectValueMust(parametersTypes, map[string]attr.Value{
350+
"sgw_acl": types.StringValue("acl"),
351+
"enable_monitoring": types.BoolValue(true),
352+
"graphite": types.StringValue("graphite"),
353+
"java_garbage_collector": types.StringValue(string(legacyOpensearch.INSTANCEPARAMETERSJAVA_GARBAGE_COLLECTOR_USE_G1_GC)),
354+
"java_heapspace": types.Int32Value(10),
355+
"java_maxmetaspace": types.Int32Value(10),
356+
"max_disk_threshold": types.Int32Value(10),
357+
"metrics_frequency": types.Int32Value(10),
358+
"metrics_prefix": types.StringValue("prefix"),
359+
"monitoring_instance_id": types.StringValue("mid"),
360+
"plugins": types.ListValueMust(types.StringType, []attr.Value{}),
361+
"syslog": types.ListValueMust(types.StringType, []attr.Value{
362+
types.StringValue("syslog"),
363+
types.StringValue("syslog2"),
364+
}),
365+
"tls_ciphers": types.ListValueMust(types.StringType, []attr.Value{
366+
types.StringValue("cipher"),
367+
types.StringValue("cipher2"),
368+
}),
369+
"tls_protocols": types.ListValueMust(types.StringType, []attr.Value{
370+
types.StringValue("TLSv1.2"),
371+
types.StringValue("TLSv1.3"),
372+
}),
373+
}),
374+
},
375+
&opensearch.PartialUpdateInstancePayload{
376+
Parameters: &opensearch.InstanceParameters{
377+
SgwAcl: new("acl"),
378+
EnableMonitoring: new(true),
379+
Graphite: new("graphite"),
380+
JavaGarbageCollector: new(string(legacyOpensearch.INSTANCEPARAMETERSJAVA_GARBAGE_COLLECTOR_USE_G1_GC)),
381+
JavaHeapspace: new(int32(10)),
382+
JavaMaxmetaspace: new(int32(10)),
383+
MaxDiskThreshold: new(int32(10)),
384+
MetricsFrequency: new(int32(10)),
385+
MetricsPrefix: new("prefix"),
386+
MonitoringInstanceId: new("mid"),
387+
Plugins: []string{},
388+
Syslog: []string{"syslog", "syslog2"},
389+
TlsCiphers: []string{"cipher", "cipher2"},
390+
TlsProtocols: []string{"TLSv1.2", "TLSv1.3"},
391+
},
392+
PlanId: new("plan"),
393+
},
394+
true,
395+
},
345396
}
346397
for _, tt := range tests {
347398
t.Run(tt.description, func(t *testing.T) {

0 commit comments

Comments
 (0)