Skip to content

Commit 9a2e988

Browse files
Use switch statements instead of if-else
1 parent 6364ea3 commit 9a2e988

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

checks/checks.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,23 +310,27 @@ func prettyPrintHTTPTest(test api.HTTPRequestTest, variables map[string]string)
310310
}
311311
if test.JSONValue != nil {
312312
var val any
313-
var op any
314-
if test.JSONValue.IntValue != nil {
313+
switch {
314+
case test.JSONValue.IntValue != nil:
315315
val = *test.JSONValue.IntValue
316-
} else if test.JSONValue.StringValue != nil {
316+
case test.JSONValue.StringValue != nil:
317317
val = *test.JSONValue.StringValue
318-
} else if test.JSONValue.BoolValue != nil {
318+
case test.JSONValue.BoolValue != nil:
319319
val = *test.JSONValue.BoolValue
320320
}
321-
if test.JSONValue.Operator == api.OpEquals {
321+
322+
var op string
323+
switch test.JSONValue.Operator {
324+
case api.OpEquals:
322325
op = "to be equal to"
323-
} else if test.JSONValue.Operator == api.OpGreaterThan {
326+
case api.OpGreaterThan:
324327
op = "to be greater than"
325-
} else if test.JSONValue.Operator == api.OpContains {
328+
case api.OpContains:
326329
op = "contains"
327-
} else if test.JSONValue.Operator == api.OpNotContains {
330+
case api.OpNotContains:
328331
op = "to not contain"
329332
}
333+
330334
expecting := fmt.Sprintf("Expecting JSON at %v %s %v", test.JSONValue.Path, op, val)
331335
return InterpolateVariables(expecting, variables)
332336
}

0 commit comments

Comments
 (0)