Skip to content

Commit

Permalink
refactor: switch to alecthomas/assert/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed May 23, 2022
1 parent fd1ae1c commit 38008eb
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 29 deletions.
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ module github.com/alecthomas/hcl
go 1.18

require (
github.com/alecthomas/assert/v2 v2.0.3
github.com/alecthomas/participle/v2 v2.0.0-alpha9
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c
github.com/stretchr/testify v1.4.0
github.com/alecthomas/repr v0.1.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
require github.com/hexops/gotextdiff v1.0.3 // indirect
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
github.com/alecthomas/assert/v2 v2.0.3 h1:WKqJODfOiQG0nEJKFKzDIG3E29CN2/4zR9XGJzKIkbg=
github.com/alecthomas/assert/v2 v2.0.3/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA=
github.com/alecthomas/participle/v2 v2.0.0-alpha9 h1:TnflwDbtf5/aG6JMbmdiA+YB3bLg0sc6yRtmAfedfN4=
github.com/alecthomas/participle/v2 v2.0.0-alpha9/go.mod h1:NumScqsC42o9x+dGj8/YqsIfhrIQjFEOFovxotbBirA=
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c h1:MVVbswUlqicyj8P/JljoocA7AyCo62gzD0O7jfvrhtE=
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2 changes: 1 addition & 1 deletion json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestJSONMarshalling(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestMarshalASTComplex(t *testing.T) {
Expand Down
11 changes: 5 additions & 6 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"math/big"
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/participle/v2/lexer"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDetach(t *testing.T) {
Expand Down Expand Up @@ -192,12 +191,12 @@ EOF
t.Run(test.name, func(t *testing.T) {
hcl, err := ParseString(test.hcl)
if test.fail {
assert.Error(t, err)
} else if assert.NoError(t, err) {
require.Error(t, err)
} else if err != nil {
normaliseAST(hcl)
assert.Equal(t,
require.Equal(t,
repr.String(test.expected, repr.Indent(" ")),
repr.String(hcl, repr.Indent(" ")))
repr.String(hcl, repr.Indent(" ")), "%s", err.Error())
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

type testSchema struct {
Expand Down
4 changes: 2 additions & 2 deletions unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

type numberTest int
Expand Down Expand Up @@ -566,7 +566,7 @@ func TestUnmarshalPointers(t *testing.T) {
f = "2017-07-07T00:00:00Z"
`), &b)
require.NoError(t, err)
require.NotNil(t, b.F)
require.NotZero(t, b.F)
require.Equal(t, time.Date(2017, 7, 7, 0, 0, 0, 0, time.UTC), *b.F)
}

Expand Down
2 changes: 1 addition & 1 deletion util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package hcl
import (
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestDedent(t *testing.T) {
Expand Down
15 changes: 8 additions & 7 deletions visitor_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package hcl

import (
"reflect"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestFind(t *testing.T) {
Expand All @@ -18,12 +19,12 @@ func TestFind(t *testing.T) {
require.NoError(t, err)

nodes := Find(ast, "attr")
require.Len(t, nodes, 1)
require.IsType(t, &Attribute{}, nodes[0])
require.Equal(t, len(nodes), 1)
require.Equal(t, reflect.TypeOf(&Attribute{}), reflect.TypeOf(nodes[0]))

nodes = Find(ast, "attr", "key", "block")
require.Len(t, nodes, 3)
require.IsType(t, &Attribute{}, nodes[0])
require.IsType(t, &Block{}, nodes[1])
require.IsType(t, &MapEntry{}, nodes[2])
require.Equal(t, len(nodes), 3)
require.Equal(t, reflect.TypeOf(&Attribute{}), reflect.TypeOf(nodes[0]))
require.Equal(t, reflect.TypeOf(&Block{}), reflect.TypeOf(nodes[1]))
require.Equal(t, reflect.TypeOf(&MapEntry{}), reflect.TypeOf(nodes[2]))
}

0 comments on commit 38008eb

Please sign in to comment.