diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml deleted file mode 100644 index 23468a4..0000000 --- a/.github/workflows/gosec.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Gosec -on: - workflow_dispatch: - push: - branches: [main] - pull_request: - branches: [main] -jobs: - tests: - runs-on: ubuntu-latest - env: - GO111MODULE: on - steps: - - name: Checkout Source - uses: actions/checkout@v4 - - name: Run Gosec Security Scanner - uses: securego/gosec@master - with: - args: --exclude-dir=examples --exclude-dir=aws ./... diff --git a/.github/workflows/multi_ver_unittest.yml b/.github/workflows/multi_ver_unittest.yml index 7fb86b8..f1dee90 100644 --- a/.github/workflows/multi_ver_unittest.yml +++ b/.github/workflows/multi_ver_unittest.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: ["1.22"] + go-version: ["1.23"] steps: - uses: actions/checkout@v4 - name: Setup Go ${{ matrix.go-version }} diff --git a/.golangci.yml b/.golangci.yml index 6ed973d..f8550ec 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - go: "1.20" + go: "1.23" issues: exclude-use-default: false diff --git a/README.md b/README.md index 850849b..e6e5db0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![WindowsUnitTest](https://github.com/nao1215/spectest/actions/workflows/windows_test.yml/badge.svg)](https://github.com/nao1215/spectest/actions/workflows/windows_test.yml) [![UnitTestExampleCodes](https://github.com/nao1215/spectest/actions/workflows/test-examples.yml/badge.svg)](https://github.com/nao1215/spectest/actions/workflows/test-examples.yml) [![reviewdog](https://github.com/nao1215/spectest/actions/workflows/reviewdog.yml/badge.svg)](https://github.com/nao1215/spectest/actions/workflows/reviewdog.yml) -[![Gosec](https://github.com/nao1215/spectest/actions/workflows/gosec.yml/badge.svg)](https://github.com/nao1215/spectest/actions/workflows/gosec.yml) ![Coverage](https://github.com/nao1215/octocovs-central-repo/blob/main//badges/nao1215/spectest/coverage.svg?raw=true) ## What is spectest? diff --git a/go.mod b/go.mod index d5e8967..78b7db8 100644 --- a/go.mod +++ b/go.mod @@ -1,22 +1,24 @@ module github.com/nao1215/spectest -go 1.22 +go 1.23.2 + +toolchain go1.23.4 require ( github.com/PaesslerAG/jsonpath v0.1.1 github.com/PuerkitoBio/goquery v1.9.2 github.com/davecgh/go-spew v1.1.1 - github.com/fatih/color v1.17.0 + github.com/fatih/color v1.18.0 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.3 github.com/n7olkachev/imgdiff v1.0.2 github.com/nao1215/diff v0.0.1 github.com/nao1215/gorky v0.2.1 github.com/nao1215/imaging v1.0.9 - github.com/nao1215/markdown v0.6.0 + github.com/nao1215/markdown v0.7.0 github.com/spf13/cobra v1.8.1 - github.com/stretchr/testify v1.9.0 - github.com/tenntenn/testtime v0.2.2 + github.com/stretchr/testify v1.10.0 + github.com/tenntenn/testtime v0.3.2 github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa ) @@ -39,7 +41,7 @@ require ( golang.org/x/image v0.19.0 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.19.0 // indirect + golang.org/x/sys v0.25.0 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ca0c407..2c80c94 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t 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/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= @@ -45,8 +45,8 @@ github.com/nao1215/gorky v0.2.1 h1:kxXYhCNBbtGru9CCSYx+QC0JZfZJ1csY3uLbb5n2WKA= github.com/nao1215/gorky v0.2.1/go.mod h1:fJNLiXzn3YkteARC8xghfHjkt+C5xtHOaRgmVnJEMOs= github.com/nao1215/imaging v1.0.9 h1:N7Jj8ibGpWCbfwU9Ftn0Kbytdt06arMk/LwNerViOmc= github.com/nao1215/imaging v1.0.9/go.mod h1:0BbOootvOGWLEEnPuUoM9HdvLCFtPoqZlAz+ASB/GB0= -github.com/nao1215/markdown v0.6.0 h1:kqhrC47K434YA1jMTUwJwSV/hla8ifN3NzehMEffI/E= -github.com/nao1215/markdown v0.6.0/go.mod h1:ObBhnNduWwPN+bu4dtv4JoLRt57ONla7l//03iHIVhY= +github.com/nao1215/markdown v0.7.0 h1:SCQkvdQXQuKJW8KaCsvBob8Afy4T4iJUAYIefWpHojE= +github.com/nao1215/markdown v0.7.0/go.mod h1:ObBhnNduWwPN+bu4dtv4JoLRt57ONla7l//03iHIVhY= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -61,10 +61,10 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -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/tenntenn/testtime v0.2.2 h1:y6K00BUNg7cRE9WpkBX/Bn+WgmV5/a3hsw7xGNyF2p0= -github.com/tenntenn/testtime v0.2.2/go.mod h1:gXZpxnMoBEV+JZwooprQ65lIbR2Kzk5PpP/deHMn+Is= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tenntenn/testtime v0.3.2 h1:uF2DQUMXTYD5+x9I4KA3y0KrBUzzdW2B8YKVFg+boi0= +github.com/tenntenn/testtime v0.3.2/go.mod h1:BB9+OlVPhFkvYVoCeaOQjAO/i7m+YeR9HCzhefH9KRg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= @@ -101,8 +101,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/mocks.go b/mocks.go index 4dca4bc..50aef9c 100644 --- a/mocks.go +++ b/mocks.go @@ -751,7 +751,7 @@ func (r *MockResponse) FixedDelay(delay int64) *MockResponse { } // Times respond the given number of times -func (r *MockResponse) Times(times uint) *MockResponse { +func (r *MockResponse) Times(times int) *MockResponse { r.mock.execCount.updateExpectCount(times) return r } @@ -1293,18 +1293,18 @@ func (r *mockInteraction) GetRequestHost() string { // execCount is used to track the number of times a mock has been executed. type execCount struct { // expect is the expected number of times the mock will be executed. - expect uint + expect int // actual is the actual number of times the mock has been executed. - actual uint + actual int } // newExecCount creates a new execCount with the given expected number of executions. -func newExecCount(expect uint) *execCount { +func newExecCount(expect int) *execCount { return &execCount{expect: expect} } // updateExpectCount updates the expected number of executions. -func (e *execCount) updateExpectCount(expect uint) { +func (e *execCount) updateExpectCount(expect int) { e.expect = expect } diff --git a/time_test.go b/time_test.go index 079617a..969d3d0 100644 --- a/time_test.go +++ b/time_test.go @@ -41,14 +41,10 @@ func TestIntervalDuration(t *testing.T) { t.Run(tt.name, func(t *testing.T) { interval := spectest.NewInterval() - if !testtime.SetTime(t, tt.fields.start) { - t.Fatal("failed to set start time") - } + testtime.SetTime(t, tt.fields.start) interval.Start() - if !testtime.SetTime(t, tt.fields.end) { - t.Fatal("failed to set end time") - } + testtime.SetTime(t, tt.fields.end) interval.End() if interval.Duration() != tt.want { @@ -64,15 +60,11 @@ func ExampleInterval_Duration() { interval := spectest.NewInterval() // Set started time. Usually, you don't need to set the time. You only call Start() method. - if !testtime.SetTime(t, time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)) { - t.Fatal("failed to set start time") - } + testtime.SetTime(t, time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)) interval.Start() // Set finished time. Usually, you don't need to set the time. You only call End() method. - if !testtime.SetTime(t, time.Date(2023, 1, 1, 0, 0, 1, 0, time.UTC)) { - t.Fatal("failed to set end time") - } + testtime.SetTime(t, time.Date(2023, 1, 1, 0, 0, 1, 0, time.UTC)) interval.End() fmt.Printf("duration=%f[s]", interval.Duration().Seconds())