Skip to content

Commit

Permalink
chore: update dependencies (#28)
Browse files Browse the repository at this point in the history
* chore: update depenmdencies

- replace `github.com/pkg/errors` with stdlib `errors`
- replace `github.com/tj/assert` with `github.com/stretchr/testify`

* update workflow go version
  • Loading branch information
gammazero authored Oct 22, 2024
1 parent 6a52e01 commit 1a9fbe3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu" ]
go: [ "1.18.x", "1.19.x" ]
go: [ "1.22.x", "1.23.x" ]
env:
COVERAGES: ""
runs-on: ${{ matrix.os }}-latest
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ module github.com/ipfs/go-ipfs-redirects-file
go 1.22

require (
github.com/pkg/errors v0.9.1
github.com/tj/assert v0.0.3
github.com/stretchr/testify v1.9.0
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.6.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
15 changes: 4 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
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/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb h1:Ywfo8sUltxogBpFuMOFRrrSifO788kAFxmvVw31PtQQ=
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb/go.mod h1:ikPs9bRWicNw3S7XpJ8sK/smGwU9WcSVU3dy9qahYBM=
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.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 3 additions & 4 deletions redirects.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strconv"
"strings"

"github.com/pkg/errors"
"github.com/ucarion/urlpath"
)

Expand Down Expand Up @@ -134,22 +133,22 @@ func Parse(r io.Reader) (rules []Rule, err error) {
// from (must parse as an absolute path)
from, err := parseFrom(fields[0])
if err != nil {
return nil, errors.Wrapf(err, "parsing 'from'")
return nil, fmt.Errorf("parsing 'from': %w", err)
}
rule.From = from

// to (must parse as an absolute path or an URL)
to, err := parseTo(fields[1])
if err != nil {
return nil, errors.Wrapf(err, "parsing 'to'")
return nil, fmt.Errorf("parsing 'to': %w", err)
}
rule.To = to

// status
if len(fields) > 2 {
code, err := parseStatus(fields[2])
if err != nil {
return nil, errors.Wrapf(err, "parsing status %q", fields[2])
return nil, fmt.Errorf("parsing status %q: %w", fields[2], err)
}

rule.Status = code
Expand Down
24 changes: 12 additions & 12 deletions redirects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/tj/assert"
"github.com/stretchr/testify/require"
)

func TestRuleIsProxy(t *testing.T) {
Expand All @@ -17,7 +17,7 @@ func TestRuleIsProxy(t *testing.T) {
To: "/blog/engineering",
}

assert.False(t, r.IsProxy())
require.False(t, r.IsProxy())
})

t.Run("with host", func(t *testing.T) {
Expand All @@ -26,7 +26,7 @@ func TestRuleIsProxy(t *testing.T) {
To: "https://site.example.com",
}

assert.True(t, r.IsProxy())
require.True(t, r.IsProxy())
})
}

Expand All @@ -38,7 +38,7 @@ func TestRuleIsRewrite(t *testing.T) {
Status: 302,
}

assert.False(t, r.IsRewrite())
require.False(t, r.IsRewrite())
})

t.Run("with 200", func(t *testing.T) {
Expand All @@ -48,7 +48,7 @@ func TestRuleIsRewrite(t *testing.T) {
Status: 200,
}

assert.True(t, r.IsRewrite())
require.True(t, r.IsRewrite())
})

t.Run("with 0", func(t *testing.T) {
Expand All @@ -57,7 +57,7 @@ func TestRuleIsRewrite(t *testing.T) {
To: "/blog/engineering",
}

assert.False(t, r.IsRewrite())
require.False(t, r.IsRewrite())
})
}

Expand All @@ -67,17 +67,17 @@ func TestParse(t *testing.T) {
/home / 301!
`))

assert.Error(t, err)
assert.Contains(t, err.Error(), "forced redirects")
require.Error(t, err)
require.ErrorContains(t, err, "forced redirects")
})

t.Run("with illegal code", func(t *testing.T) {
_, err := Parse(strings.NewReader(`
/home / 42
`))

assert.Error(t, err)
assert.Contains(t, err.Error(), "status code 42 is not supported")
require.Error(t, err)
require.ErrorContains(t, err, "status code 42 is not supported")
})

t.Run("with too large file", func(t *testing.T) {
Expand All @@ -95,8 +95,8 @@ func TestParse(t *testing.T) {

_, err := ParseString(text)

assert.Error(t, err)
assert.Contains(t, err.Error(), "redirects file size cannot exceed")
require.Error(t, err)
require.ErrorContains(t, err, "redirects file size cannot exceed")
})
}

Expand Down

0 comments on commit 1a9fbe3

Please sign in to comment.