Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: go1.16 required now, so drop support for go1.9 to go1.15 #221

Merged
merged 1 commit into from
Oct 9, 2022
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
14 changes: 2 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.9.x, 1.10.x, 1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x, tip]
go-version: [1.16.x, 1.17.x, 1.18.x, tip]
full-tests: [false]
include:
- go-version: 1.19.x
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
if: matrix.full-tests
run: |
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh |
sh -s -- -b $HOME/go/bin v1.49.0
sh -s -- -b $HOME/go/bin v1.50.0
echo $PATH
$HOME/go/bin/golangci-lint run --max-issues-per-linter 0 \
--max-same-issues 0 \
Expand Down Expand Up @@ -71,16 +71,6 @@ jobs:
GO_TEST_RACE_SAFE_FLAGS="$cover_flags-race-safe.out"
fi

case ${{ matrix.go-version }} in
1.9.x | 1.10.x) # Before go 1.11, go modules are not available
mkdir -p ../src/github.com/maxatome
ln -s $(pwd) ../src/github.com/$GITHUB_REPOSITORY
export GOPATH=$(dirname $(pwd))
cd $GOPATH/src/github.com/$GITHUB_REPOSITORY
go get -t ./...
;;
esac

export GORACE="halt_on_error=1"
echo "CLASSIC ==========================================="
go test $GO_TEST_FLAGS ./...
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
run:
go: '1.9'
go: '1.16'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ go-testdeep

**Extremely flexible golang deep comparison, extends the go testing package.**

Currently supports go 1.9 → 1.19.
Currently supports go 1.16 → 1.19.

- [Latest news](#latest-news)
- [Synopsis](#synopsis)
Expand Down Expand Up @@ -203,7 +203,7 @@ details.**
## Installation

```sh
$ go get -u github.com/maxatome/go-testdeep
$ go get github.com/maxatome/go-testdeep
```


Expand Down
4 changes: 2 additions & 2 deletions helpers/tdhttp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"encoding/json"
"encoding/xml"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -103,7 +103,7 @@ func Example() {
return
}
case "application/x-www-form-urlencoded":
b, err := ioutil.ReadAll(req.Body)
b, err := io.ReadAll(req.Body)
if err != nil {
http.Error(w, "Bad request", http.StatusBadRequest)
return
Expand Down
4 changes: 2 additions & 2 deletions helpers/tdhttp/internal/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package internal_test

import (
"bytes"
"io/ioutil"
"io"
"net/http"
"testing"

Expand All @@ -28,7 +28,7 @@ func newResponse(body string) *http.Response {
"A": []string{"foo"},
"B": []string{"bar"},
},
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
Body: io.NopCloser(bytes.NewBufferString(body)),
}
}

Expand Down
25 changes: 12 additions & 13 deletions helpers/tdhttp/multipart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package tdhttp_test
import (
"bytes"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
Expand Down Expand Up @@ -38,7 +37,7 @@ func TestMultipartPart(t *testing.T) {
}

// Full empty
b, err := ioutil.ReadAll(&tdhttp.MultipartPart{})
b, err := io.ReadAll(&tdhttp.MultipartPart{})
assert.CmpNoError(err)
assert.Len(b, 0)

Expand Down Expand Up @@ -143,11 +142,11 @@ hey!
yo!`)

// With file name
dir, err := ioutil.TempDir("", "multipart")
dir, err := os.MkdirTemp("", "multipart")
require.CmpNoError(err)
defer os.RemoveAll(dir)
filePath := filepath.Join(dir, "body.txt")
require.CmpNoError(ioutil.WriteFile(filePath, []byte("hey!\nyo!"), 0666))
require.CmpNoError(os.WriteFile(filePath, []byte("hey!\nyo!"), 0666))

check(tdhttp.NewMultipartPartFile("pipo", filePath),
`Content-Disposition: form-data; name="pipo"; filename="body.txt"%CR
Expand All @@ -165,7 +164,7 @@ hey!
yo!`)

// Error during os.Open
_, err = ioutil.ReadAll(
_, err = io.ReadAll(
tdhttp.NewMultipartPartFile("pipo", filepath.Join(dir, "unknown.xxx")),
)
assert.CmpError(err)
Expand All @@ -174,11 +173,11 @@ yo!`)
func TestMultipartBody(t *testing.T) {
assert, require := td.AssertRequire(t)

dir, err := ioutil.TempDir("", "multipart")
dir, err := os.MkdirTemp("", "multipart")
require.CmpNoError(err)
defer os.RemoveAll(dir)
filePath := filepath.Join(dir, "body.txt")
require.CmpNoError(ioutil.WriteFile(filePath, []byte("hey!\nyo!"), 0666))
require.CmpNoError(os.WriteFile(filePath, []byte("hey!\nyo!"), 0666))

for _, boundary := range []struct{ in, out string }{
{in: "", out: "go-testdeep-42"},
Expand Down Expand Up @@ -251,47 +250,47 @@ Content-Disposition: form-data; name="io"%CR
if assert.CmpNoError(err) {
assert.Cmp(part.FormName(), "pipo")
assert.Cmp(part.FileName(), "")
assert.Smuggle(part, ioutil.ReadAll, td.String("pipo!\nbingo!"))
assert.Smuggle(part, io.ReadAll, td.String("pipo!\nbingo!"))
}

// 1
part, err = rd.NextPart()
if assert.CmpNoError(err) {
assert.Cmp(part.FormName(), "file")
assert.Cmp(part.FileName(), "body.txt")
assert.Smuggle(part, ioutil.ReadAll, td.String("hey!\nyo!"))
assert.Smuggle(part, io.ReadAll, td.String("hey!\nyo!"))
}

// 2
part, err = rd.NextPart()
if assert.CmpNoError(err) {
assert.Cmp(part.FormName(), "string")
assert.Cmp(part.FileName(), "")
assert.Smuggle(part, ioutil.ReadAll, td.String("zip!\nzap!"))
assert.Smuggle(part, io.ReadAll, td.String("zip!\nzap!"))
}

// 3
part, err = rd.NextPart()
if assert.CmpNoError(err) {
assert.Cmp(part.FormName(), "bytes")
assert.Cmp(part.FileName(), "")
assert.Smuggle(part, ioutil.ReadAll, td.String(`{"ola":"hello"}`))
assert.Smuggle(part, io.ReadAll, td.String(`{"ola":"hello"}`))
}

// 4
part, err = rd.NextPart()
if assert.CmpNoError(err) {
assert.Cmp(part.FormName(), "io")
assert.Cmp(part.FileName(), "")
assert.Smuggle(part, ioutil.ReadAll, td.String(""))
assert.Smuggle(part, io.ReadAll, td.String(""))
}

// 5
part, err = rd.NextPart()
if assert.CmpNoError(err) {
assert.Cmp(part.FormName(), "")
assert.Cmp(part.FileName(), "")
assert.Smuggle(part, ioutil.ReadAll, td.String(""))
assert.Smuggle(part, io.ReadAll, td.String(""))
}

// EOF
Expand Down
8 changes: 4 additions & 4 deletions helpers/tdhttp/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package tdhttp_test

import (
"io/ioutil"
"io"
"net/http"
"net/url"
"testing"
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestNewRequest(tt *testing.T) {
td.StructFields{
"URL": td.String("/path"),
"Body": td.Smuggle(
ioutil.ReadAll,
io.ReadAll,
[]byte("param1=val1&param1=val2&param2=zip"),
),
}))
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestNewJSONRequest(tt *testing.T) {
t.String(req.Header.Get("Foo"), "Bar")
t.String(req.Header.Get("Zip"), "Test")

body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if t.CmpNoError(err, "read request body") {
t.String(string(body), `{"name":"Bob"}`)
}
Expand Down Expand Up @@ -445,7 +445,7 @@ func TestNewXMLRequest(tt *testing.T) {
t.String(req.Header.Get("Foo"), "Bar")
t.String(req.Header.Get("Zip"), "Test")

body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if t.CmpNoError(err, "read request body") {
t.String(string(body), `<TestStruct><name>Bob</name></TestStruct>`)
}
Expand Down
14 changes: 6 additions & 8 deletions helpers/tdsuite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ var tType = reflect.TypeOf((*td.T)(nil))
// tests suite, Setup method is called once before any test runs. If
// Setup returns an error, the tests suite aborts: no tests are run.
//
// Starting go1.14, t.Cleanup() can be called in Setup method. It can
// replace the definition of a [Destroy] method. It can also be used
// together, in this case cleanup registered functions are called
// after [Destroy].
// t.Cleanup() can be called in Setup method. It can replace the
// definition of a [Destroy] method. It can also be used together, in
// this case cleanup registered functions are called after [Destroy].
type Setup interface {
Setup(t *td.T) error
}
Expand All @@ -37,10 +36,9 @@ type Setup interface {
// itself. If PreTest returns an error, the subtest aborts: the test
// is not run.
//
// Starting go1.14, t.Cleanup() can be called in PreTest method. It can
// replace the definition of a [PostTest] method. It can also be used
// together, in this case cleanup registered functions are called
// after [PostTest].
// t.Cleanup() can be called in PreTest method. It can replace the
// definition of a [PostTest] method. It can also be used together, in
// this case cleanup registered functions are called after [PostTest].
type PreTest interface {
PreTest(t *td.T, testName string) error
}
Expand Down
104 changes: 0 additions & 104 deletions helpers/tdsuite/suite_go114_test.go

This file was deleted.

Loading