Skip to content

Commit

Permalink
Fixed some JSON unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Jul 3, 2023
1 parent 6cd71a1 commit 8f4804c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ func TestJSONParseVersion(t *testing.T) {
fmt.Println(string(data))
require.NoError(t, err)

dump := fmt.Sprintf("%s,%s,%s,%s,%v,%s",
v.major, v.minor, v.patch,
v.prerelases, v.numericPrereleases,
v.builds)
require.Equal(t, "1,2,3,[aaa 4 5 6],[false true true true],[bbb 7 8 9]", dump)

var u Version
err = json.Unmarshal(data, &u)
require.NoError(t, err)

require.Equal(t, testVersion, v.String())
dump := fmt.Sprintf("%s,%s,%s,%s,%v,%s",
u.major, u.minor, u.patch,
u.prerelases, u.numericPrereleases,
u.builds)
require.Equal(t, "1,2,3,[aaa 4 5 6],[false true true true],[bbb 7 8 9]", dump)
require.Equal(t, testVersion, u.String())

err = json.Unmarshal([]byte(`"invalid"`), &u)
require.Error(t, err)
Expand All @@ -53,8 +51,7 @@ func TestJSONParseRelaxedVersion(t *testing.T) {
var u RelaxedVersion
err = json.Unmarshal(data, &u)
require.NoError(t, err)

require.Equal(t, testVersion, v.String())
require.Equal(t, testVersion, u.String())

err = json.Unmarshal([]byte(`"invalid"`), &u)
require.NoError(t, err)
Expand Down

0 comments on commit 8f4804c

Please sign in to comment.