Skip to content

Commit 07ea298

Browse files
committed
fix(opensearch): acc tests
1 parent 85d1c55 commit 07ea298

5 files changed

Lines changed: 117 additions & 282 deletions

File tree

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)