Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
# support two latest major versions of Go, following the Go security policy
# in which these versions get security updates. See https://golang.org/security
go-version: [1.20.x, 1.21.x]
go-version: [1.24.x, 1.25.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.1-alpine3.18 AS builder
FROM golang:1.25-alpine AS builder

RUN apk update && apk add --no-cache git

Expand All @@ -8,7 +8,7 @@ RUN go get ./
RUN CGO_ENABLED=0 go build -o /app/http-mockery
RUN chmod +x /app/http-mockery

FROM alpine:3.18
FROM alpine:3.23

COPY --from=builder /app/http-mockery /go/bin/http-mockery
RUN apk update && apk add --no-cache ca-certificates
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/UpCloudLtd/http-mockery

go 1.21
go 1.24

require (
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.11.1
github.com/valyala/fasttemplate v1.2.2
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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/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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
Expand Down
10 changes: 4 additions & 6 deletions pkg/mockery/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ import (
"github.com/valyala/fasttemplate"
)

var (
ErrEndpointNotFound = fmt.Errorf("no matching endpoint found")
)
var ErrEndpointNotFound = fmt.Errorf("no matching endpoint found")

var validHTTPMethods = []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPost, http.MethodDelete}
var validHTTPMethods = []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch}

const (
EndpointTypeNormal = "normal"
Expand Down Expand Up @@ -91,7 +89,7 @@ func (s MockHandler) ValidateConfig() error {
}
}
if !validMethod {
return fmt.Errorf(fmt.Sprintf("Invalid HTTP method (%s) for endpoint %s. Allowed: %+v", endpoint.Method, endpoint.Uri, validHTTPMethods))
return fmt.Errorf("invalid HTTP method (%s) for endpoint %s. Allowed: %+v", endpoint.Method, endpoint.Uri, validHTTPMethods)
}

validType := false
Expand All @@ -102,7 +100,7 @@ func (s MockHandler) ValidateConfig() error {
}
}
if !validType {
return fmt.Errorf(fmt.Sprintf("Invalid endpoint type (%s) for endpoint %s. Allowed: %+v", endpoint.Type, endpoint.Uri, validEndpointTypes))
return fmt.Errorf("invalid endpoint type (%s) for endpoint %s. Allowed: %+v", endpoint.Type, endpoint.Uri, validEndpointTypes)
}

if endpoint.Template != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/mockery/mockery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestConfigValidation(t *testing.T) {

testMocker.Config.Endpoints[0].Method = "TRACE"
err = testMocker.ValidateConfig()
assert.ErrorContains(t, err, "Invalid HTTP method", "Config validation should fail on unsupported HTTP method")
assert.ErrorContains(t, err, "invalid HTTP method", "Config validation should fail on unsupported HTTP method")
testMocker.Config = testingConfig()

testMocker.Config.Endpoints[0].ResponseCode = 0
Expand Down
Loading