Skip to content

Commit

Permalink
Merge pull request #58 from yutopp/feature/update_deps_and_add_tests
Browse files Browse the repository at this point in the history
Feature/update deps and add tests
  • Loading branch information
yutopp committed Jul 2, 2023
2 parents 9a7a975 + 39f0a77 commit 73d0006
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 227 deletions.
3 changes: 3 additions & 0 deletions .golangci.yaml
@@ -0,0 +1,3 @@
linters:
enable:
- nilerr
8 changes: 4 additions & 4 deletions Makefile
Expand Up @@ -9,8 +9,8 @@ check: fmt lint vet
.PHONY: download-ci-tools
download-ci-tools:
go install golang.org/x/tools/cmd/goimports@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.1
curl -sSfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s v0.14.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.53.1
curl -sSfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s v0.14.2

.PHONY: fmt
fmt:
Expand All @@ -19,11 +19,11 @@ fmt:

.PHONY: lint
lint:
./bin/golangci-lint run ./...
./bin/golangci-lint run

.PHONY: lint-ci
lint-ci:
./bin/golangci-lint run ./... | \
./bin/golangci-lint run | \
./bin/reviewdog -f=golangci-lint -reporter=github-pr-review -filter-mode=nofilter

.PHONY: vet
Expand Down
22 changes: 11 additions & 11 deletions chunk_header_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestChunkBasicHeader(t *testing.T) {
Expand Down Expand Up @@ -116,8 +116,8 @@ func TestChunkBasicHeader(t *testing.T) {

buf := new(bytes.Buffer)
err := encodeChunkBasicHeader(buf, tc.value)
assert.Nil(t, err)
assert.Equal(t, tc.binary, buf.Bytes())
require.Nil(t, err)
require.Equal(t, tc.binary, buf.Bytes())
})
}
})
Expand All @@ -132,8 +132,8 @@ func TestChunkBasicHeader(t *testing.T) {
r := bytes.NewReader(tc.binary)
var mh chunkBasicHeader
err := decodeChunkBasicHeader(r, nil, &mh)
assert.Nil(t, err)
assert.Equal(t, tc.value, &mh)
require.Nil(t, err)
require.Equal(t, tc.value, &mh)
})
}
})
Expand All @@ -146,7 +146,7 @@ func TestChunkBasicHeaderError(t *testing.T) {
fmt: 3,
chunkStreamID: 65600,
})
assert.EqualError(t, err, "Chunk stream id is out of range: 65600 must be in range [2, 65599]")
require.EqualError(t, err, "Chunk stream id is out of range: 65600 must be in range [2, 65599]")
})

t.Run("Out of range(under)", func(t *testing.T) {
Expand All @@ -155,7 +155,7 @@ func TestChunkBasicHeaderError(t *testing.T) {
fmt: 3,
chunkStreamID: 1,
})
assert.EqualError(t, err, "Chunk stream id is out of range: 1 must be in range [2, 65599]")
require.EqualError(t, err, "Chunk stream id is out of range: 1 must be in range [2, 65599]")
})
}

Expand Down Expand Up @@ -367,8 +367,8 @@ func TestChunkMessageHeader(t *testing.T) {

buf := new(bytes.Buffer)
err := encodeChunkMessageHeader(buf, tc.fmt, tc.value)
assert.Nil(t, err)
assert.Equal(t, tc.binary, buf.Bytes())
require.Nil(t, err)
require.Equal(t, tc.binary, buf.Bytes())
})
}
})
Expand All @@ -383,8 +383,8 @@ func TestChunkMessageHeader(t *testing.T) {
r := bytes.NewReader(tc.binary)
var mh chunkMessageHeader
err := decodeChunkMessageHeader(r, tc.fmt, nil, &mh)
assert.Nil(t, err)
assert.Equal(t, tc.value, &mh)
require.Nil(t, err)
require.Equal(t, tc.value, &mh)
})
}
})
Expand Down

0 comments on commit 73d0006

Please sign in to comment.