Skip to content

Commit 0dc1edf

Browse files
committed
Fixed tests
1 parent 8a64550 commit 0dc1edf

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

internal/template/dashboard.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,10 @@ func getVariableID(ctx context.Context, thingID string, variableName string, fet
7676
}
7777

7878
for _, v := range thing.Properties {
79-
if v.VariableName == &variableName {
79+
if v.VariableName != nil && *v.VariableName == variableName {
8080
return v.Id, nil
8181
}
8282
}
8383

8484
return "", fmt.Errorf("thing with id %s doesn't have variable with name %s : %w", thingID, variableName, err)
8585
}
86-
87-
func dereferenceString(s *string) string {
88-
if s == nil {
89-
return ""
90-
}
91-
return *s
92-
}

internal/template/load_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -185,28 +185,24 @@ func TestLoadDashboard(t *testing.T) {
185185
override: nil,
186186
want: dashboardDetailed,
187187
},
188-
189188
{
190189
name: "dashboard with wrong options to be filtered out",
191190
file: "testdata/dashboard-wrong-options.yaml",
192191
override: nil,
193192
want: dashboardDetailed,
194193
},
195-
196194
{
197195
name: "dashboard without options, should have a not nil map",
198196
file: "testdata/dashboard-no-options.yaml",
199197
override: nil,
200198
want: dashboardNoOptions,
201199
},
202-
203200
{
204201
name: "dashboard with variable, mocked variable id is concatenation of thing_id and variable_id",
205202
file: "testdata/dashboard-with-variable.yaml",
206203
override: nil,
207204
want: dashboardWithVariable,
208205
},
209-
210206
{
211207
name: "dashboard with variable, thing is overridden",
212208
file: "testdata/dashboard-with-variable.yaml",

0 commit comments

Comments
 (0)