Skip to content

Commit

Permalink
test: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrode committed Nov 10, 2024
1 parent 41cfd4b commit 6c2fbcb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/lib/api/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestResponse_ToGenericJson(t *testing.T) {
if !ok {
t.Fatalf("responseJsonObj should have status code field")
}
if statusCode != json.Number("200") {
if statusCode != float64(200) {
t.Errorf("responseJson had wrong statuscode, expected 200, got: %d", statusCode)
}
jsonHeaders, ok := jsonObjResp["header"]
Expand Down
21 changes: 10 additions & 11 deletions pkg/lib/util/json_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"encoding/json"
"fmt"
"testing"

Expand Down Expand Up @@ -97,7 +96,7 @@ welt:1

for _, v := range testCases {
var out JsonObject
oErr := UnmarshalWithNumber([]byte(v.iJson), &out)
oErr := Unmarshal([]byte(v.iJson), &out)

go_test_utils.AssertErrorEquals(t, oErr, v.eError)
}
Expand All @@ -114,15 +113,15 @@ func TestRemoveComments(t *testing.T) {
"hallo":2
}`,
JsonObject{
"hallo": json.Number("2"),
"hallo": float64(2),
},
},
{
`{
"hallo":2
}`,
JsonObject{
"hallo": json.Number("2"),
"hallo": float64(2),
},
},
{
Expand All @@ -133,7 +132,7 @@ func TestRemoveComments(t *testing.T) {
#line2
}`,
JsonObject{
"hallo": json.Number("2"),
"hallo": float64(2),
},
},
{
Expand All @@ -145,18 +144,18 @@ func TestRemoveComments(t *testing.T) {
"hey":"ha"
}`,
JsonObject{
"hallo": json.Number("2"),
"hallo": float64(2),
"hey": "ha",
},
},
}

for _, v := range testCases {
var out JsonObject
UnmarshalWithNumber([]byte(v.iJson), &out)
Unmarshal([]byte(v.iJson), &out)
for k, v := range v.eOut {
if out[k] != v {
t.Errorf("[%s] Have '%v' != '%f' want", k, out[k], v)
t.Errorf("[%s] Have %T '%v' != '%f' want", k, k, out[k], v)
}
}
}
Expand All @@ -172,7 +171,7 @@ func TestCJSONUnmarshalSyntaxErr(t *testing.T) {
{
`{"hallo":3}`,
JsonObject{
"hallo": json.Number("3"),
"hallo": float64(3),
},
nil,
},
Expand Down Expand Up @@ -245,7 +244,7 @@ func TestCJSONUnmarshalSyntaxErr(t *testing.T) {

for _, v := range testCases {
oObject := JsonObject{}
oErr := UnmarshalWithNumber([]byte(v.cjsonString), &oObject)
oErr := Unmarshal([]byte(v.cjsonString), &oObject)

go_test_utils.AssertErrorEquals(t, oErr, v.eError)
if oErr == nil {
Expand All @@ -270,7 +269,7 @@ func TestCJSONUnmarshalTypeErr(t *testing.T) {

var oObject expectedStructure

oErr := UnmarshalWithNumber(
oErr := Unmarshal(
[]byte(cjsonString),
&oObject,
)
Expand Down

0 comments on commit 6c2fbcb

Please sign in to comment.