diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44811d2..94b63bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 8d842ed..95947bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 diff --git a/go.mod b/go.mod index 0c5fd58..27ae0ad 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 803650f..45c15b1 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/mockery/mockery.go b/pkg/mockery/mockery.go index 8247eb7..b2b5893 100644 --- a/pkg/mockery/mockery.go +++ b/pkg/mockery/mockery.go @@ -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" @@ -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 @@ -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 != "" { diff --git a/pkg/mockery/mockery_test.go b/pkg/mockery/mockery_test.go index 761f660..bf926a7 100644 --- a/pkg/mockery/mockery_test.go +++ b/pkg/mockery/mockery_test.go @@ -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