Skip to content

Commit

Permalink
Merge pull request #30 from bzimmer/updates
Browse files Browse the repository at this point in the history
upgrade go version; linting fixes
  • Loading branch information
bzimmer authored May 31, 2024
2 parents d96e536 + f2b5fe8 commit 3107a3b
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ linters:
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
- exhaustive # checks exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # forbids identifiers
Expand Down Expand Up @@ -242,9 +241,11 @@ linters:
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- unused # checks unused constants, variables, functions and types
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
- zerologlint # Detects the wrong usage of zerolog that a user forgets to dispatch with Send or Msg

## you may want to enable
#- decorder # checks declaration order and count of types, constants, variables and functions
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ changelog:
- '^test:'
- '^Merge pull request'
announce:
skip: "true"
skip: true
8 changes: 4 additions & 4 deletions cyclinganalytics/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func TestUpload(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
a := assert.New(t)
mux := http.NewServeMux()
mux.HandleFunc("/me/upload", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/me/upload", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&cyclinganalytics.Upload{}))
})
mux.HandleFunc("/user/2298801/upload", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/user/2298801/upload", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&cyclinganalytics.Upload{}))
})
Expand Down Expand Up @@ -110,11 +110,11 @@ func TestStatus(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
a := assert.New(t)
mux := http.NewServeMux()
mux.HandleFunc("/me/upload/1891982", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/me/upload/1891982", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&cyclinganalytics.Upload{}))
})
mux.HandleFunc("/user/882722/upload/1891982", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/user/882722/upload/1891982", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&cyclinganalytics.Upload{}))
})
Expand Down
2 changes: 1 addition & 1 deletion cyclinganalytics/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestUser(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
a := assert.New(t)
mux := http.NewServeMux()
mux.HandleFunc("/me", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/me", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&cyclinganalytics.User{
Expand Down
19 changes: 8 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
module github.com/bzimmer/activity

go 1.19
go 1.22.3

require (
github.com/bzimmer/httpwares v0.1.3
github.com/martinlindhe/unit v0.0.0-20230420213220-4adfd7d0a0d6
github.com/stretchr/testify v1.8.1
github.com/twpayne/go-geom v1.5.2
github.com/twpayne/go-gpx v1.3.0
github.com/twpayne/go-geom v1.5.4
github.com/twpayne/go-gpx v1.3.1
github.com/twpayne/go-polyline v1.1.1
golang.org/x/oauth2 v0.7.0
golang.org/x/sync v0.2.0
golang.org/x/time v0.3.0
golang.org/x/oauth2 v0.20.0
golang.org/x/sync v0.7.0
golang.org/x/time v0.5.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
60 changes: 26 additions & 34 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/bzimmer/httpwares v0.1.3 h1:Haw1fGBRW51iv7O2NIkIZyuUt3XLZZG+ePd6NEwbD5Q=
github.com/bzimmer/httpwares v0.1.3/go.mod h1:8pi184rxXR7Pbn7cNL8uMPeqYA8+DbQSl4oOQE5q4Vk=
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/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
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/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/martinlindhe/unit v0.0.0-20230420213220-4adfd7d0a0d6 h1:muzoir7BEy+lDPqdROr57IjJBP7OydzCg0VDhZtdG+w=
github.com/martinlindhe/unit v0.0.0-20230420213220-4adfd7d0a0d6/go.mod h1:8QbxAolnDKw/JhUJMU80MRjHjEs0tLwkjZAPrTn+xLA=
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/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
Expand All @@ -31,35 +36,22 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/twpayne/go-geom v1.5.2 h1:LyRfBX2W0LM7XN/bGqX0XxrJ7SZc3XwmxU4aj4kSoxw=
github.com/twpayne/go-geom v1.5.2/go.mod h1:3z6O2sAnGtGCXx4Q+5nPOLCA5e8WI2t3cthdb1P2HH8=
github.com/twpayne/go-gpx v1.3.0 h1:YWin/18NpoMiaKZHAsGsOmR0EXwAW302o97reDPQjvE=
github.com/twpayne/go-gpx v1.3.0/go.mod h1:kz0GrsCRcbnAQXD9/jfKhkbMd3YxN3niqvYSq8YTx7I=
github.com/twpayne/go-geom v1.5.4 h1:b8fiZd0SsEmQEeUdz2atT6KggF1KHiaZIi3DGi5p+sI=
github.com/twpayne/go-geom v1.5.4/go.mod h1:Hw8RszQ2/d9Y/KfOm9CvUJo78BOoIA5g0e4P7JCVKvo=
github.com/twpayne/go-gpx v1.3.1 h1:V7fjRvQa4Hl5kEgft7JGOQYhOtPEBFbsd/5Eao4LgBM=
github.com/twpayne/go-gpx v1.3.1/go.mod h1:cOFdNmqGjdjb3POPoecMEUko160iS9AuJvknftGW7jI=
github.com/twpayne/go-polyline v1.1.1 h1:/tSF1BR7rN4HWj4XKqvRUNrCiYVMCvywxTFVofvDV0w=
github.com/twpayne/go-polyline v1.1.1/go.mod h1:ybd9IWWivW/rlXPXuuckeKUyF3yrIim+iqA7kSl4NFY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
6 changes: 3 additions & 3 deletions rwgps/trips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestTrip(t *testing.T) {
{
name: "invalid trip",
before: func(mux *http.ServeMux) {
mux.HandleFunc("/trips/94.json", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/trips/94.json", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
},
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestPagination(t *testing.T) {
name: "valid routes",
routes: true,
before: func(mux *http.ServeMux) {
mux.HandleFunc("/users/88272/routes.json", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/users/88272/routes.json", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(struct {
Results []*rwgps.Trip `json:"results"`
Expand All @@ -136,7 +136,7 @@ func TestPagination(t *testing.T) {
name: "valid trips",
trips: true,
before: func(mux *http.ServeMux) {
mux.HandleFunc("/users/88272/trips.json", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/users/88272/trips.json", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(struct {
Results []*rwgps.Trip `json:"results"`
Expand Down
2 changes: 1 addition & 1 deletion rwgps/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestAthlete(t *testing.T) {
{
name: "athlete not authorized",
before: func(mux *http.ServeMux) {
mux.HandleFunc("/users/current.json", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/users/current.json", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusUnauthorized)
})
},
Expand Down
6 changes: 3 additions & 3 deletions strava/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func TestActivityStreams(t *testing.T) {
{
name: "invalid",
streams: []string{"foo", "bar", "baz"},
before: func(mux *http.ServeMux) {},
before: func(_ *http.ServeMux) {},
after: func(streams *strava.Streams, err error) {
a.Error(err)
a.Nil(streams)
Expand Down Expand Up @@ -407,11 +407,11 @@ func TestUpload(t *testing.T) {
Status: "ok",
ActivityID: 54321,
}
mux.HandleFunc("/uploads", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/uploads", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(up))
})
mux.HandleFunc("/uploads/12345", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/uploads/12345", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(up))
})
Expand Down
4 changes: 2 additions & 2 deletions strava/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func TestRoute(t *testing.T) {
},
{
name: "invalid route",
before: func(mux *http.ServeMux) {},
after: func(route *strava.Route, err error) {
before: func(_ *http.ServeMux) {},
after: func(_ *strava.Route, err error) {
a.Error(err)
},
},
Expand Down
4 changes: 2 additions & 2 deletions zwift/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestActivity(t *testing.T) {
a := assert.New(t)

mux := http.NewServeMux()
mux.HandleFunc("/api/profiles/1037/activities/882920", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/api/profiles/1037/activities/882920", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&zwift.Activity{ID: 882920}))
})
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestActivities(t *testing.T) {
a := assert.New(t)

mux := http.NewServeMux()
mux.HandleFunc("/api/profiles/1037/activities/", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/api/profiles/1037/activities/", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
var res []*zwift.Activity
for i := 0; i < 5; i++ {
Expand Down
2 changes: 1 addition & 1 deletion zwift/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestRefresh(t *testing.T) {
a := assert.New(t)

mux := http.NewServeMux()
mux.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/token", func(w http.ResponseWriter, _ *http.Request) {
n, err := w.Write([]byte(`{
"access_token":"000aaabbbccc999",
"token_type":"bearer",
Expand Down
4 changes: 2 additions & 2 deletions zwift/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func TestProfile(t *testing.T) {
a := assert.New(t)

mux := http.NewServeMux()
mux.HandleFunc("/api/profiles/abcxyz", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/api/profiles/abcxyz", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&zwift.Profile{FirstName: "barney"}))
})
mux.HandleFunc("/api/profiles/me", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/api/profiles/me", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&zwift.Profile{FirstName: "betty"}))
})
Expand Down
6 changes: 3 additions & 3 deletions zwift/zwift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestTokenRefresh(t *testing.T) {
a := assert.New(t)

mux := http.NewServeMux()
mux.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/token", func(w http.ResponseWriter, _ *http.Request) {
n, err := w.Write([]byte(`{
"access_token":"11223344556677889900",
"token_type":"bearer",
Expand All @@ -52,7 +52,7 @@ func TestTokenRefresh(t *testing.T) {
a.Greater(n, 0)
a.NoError(err)
})
mux.HandleFunc("/api/profiles/abcxyz", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/api/profiles/abcxyz", func(w http.ResponseWriter, _ *http.Request) {
enc := json.NewEncoder(w)
a.NoError(enc.Encode(&zwift.Profile{FirstName: "barney"}))
})
Expand All @@ -74,7 +74,7 @@ func TestTokenRefresh(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
svr := httptest.NewServer(mux)
defer svr.Close()

Expand Down

0 comments on commit 3107a3b

Please sign in to comment.