Skip to content

Commit 2cdbd1f

Browse files
author
Yago Carlos Fernandez Gou
committed
Adjust resource_test
1 parent ff8151b commit 2cdbd1f

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

stackit/internal/services/intake/runner/resource_test.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package runner
22

33
import (
4-
"context"
54
"fmt"
65
"testing"
76

@@ -20,6 +19,7 @@ func TestMapFields(t *testing.T) {
2019
description string
2120
input *intake.IntakeRunnerResponse
2221
model *Model
22+
region string
2323
expected *Model
2424
wantErr bool
2525
}{
@@ -35,8 +35,8 @@ func TestMapFields(t *testing.T) {
3535
},
3636
&Model{
3737
ProjectId: types.StringValue("pid"),
38-
Region: types.StringValue("eu01"),
3938
},
39+
"eu01",
4040
&Model{
4141
Id: types.StringValue(fmt.Sprintf("pid,eu01,%s", runnerId)),
4242
ProjectId: types.StringValue("pid"),
@@ -54,13 +54,15 @@ func TestMapFields(t *testing.T) {
5454
"nil input",
5555
nil,
5656
&Model{},
57+
"eu01",
5758
nil,
5859
true,
5960
},
6061
{
6162
"nil model",
6263
&intake.IntakeRunnerResponse{},
6364
nil,
65+
"eu01",
6466
nil,
6567
true,
6668
},
@@ -72,8 +74,8 @@ func TestMapFields(t *testing.T) {
7274
},
7375
&Model{
7476
ProjectId: types.StringValue("pid"),
75-
Region: types.StringValue("eu01"),
7677
},
78+
"eu01",
7779
&Model{
7880
Id: types.StringValue("pid,eu01,"),
7981
ProjectId: types.StringValue("pid"),
@@ -90,7 +92,7 @@ func TestMapFields(t *testing.T) {
9092
}
9193
for _, tt := range tests {
9294
t.Run(tt.description, func(t *testing.T) {
93-
err := mapFields(tt.input, tt.model)
95+
err := mapFields(tt.input, tt.model, tt.region)
9496
if (err != nil) != tt.wantErr {
9597
t.Errorf("mapFields error = %v, wantErr %v", err, tt.wantErr)
9698
return
@@ -209,10 +211,7 @@ func TestToUpdatePayload(t *testing.T) {
209211
"empty model",
210212
&Model{},
211213
&Model{},
212-
&intake.UpdateIntakeRunnerPayload{
213-
Description: utils.Ptr(""),
214-
Labels: &map[string]string{},
215-
},
214+
&intake.UpdateIntakeRunnerPayload{},
216215
false,
217216
},
218217
{
@@ -231,14 +230,6 @@ func TestToUpdatePayload(t *testing.T) {
231230
}
232231
for _, tt := range tests {
233232
t.Run(tt.description, func(t *testing.T) {
234-
var labels map[string]string
235-
if tt.model != nil && !tt.model.Labels.IsNull() && !tt.model.Labels.IsUnknown() {
236-
diags := tt.model.Labels.ElementsAs(context.Background(), &labels, false)
237-
if diags.HasError() {
238-
t.Fatalf("error preparing test %v", diags)
239-
}
240-
}
241-
242233
payload, err := toUpdatePayload(tt.model, tt.state)
243234
if (err != nil) != tt.wantErr {
244235
t.Errorf("toUpdatePayload error = %v, wantErr %v", err, tt.wantErr)

0 commit comments

Comments
 (0)