Merge pull request #296 from jzelinskie/require-all
Replace last usage of assert with require
This commit is contained in:
commit
b028a36424
6 changed files with 31 additions and 31 deletions
|
@ -3,7 +3,7 @@ package bittorrent
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
|
@ -23,7 +23,7 @@ func TestNew(t *testing.T) {
|
|||
|
||||
for _, tt := range table {
|
||||
got, err := NewEvent(tt.data)
|
||||
assert.Equal(t, err, tt.expectedErr, "errors should equal the expected value")
|
||||
assert.Equal(t, got, tt.expected, "events should equal the expected value")
|
||||
require.Equal(t, err, tt.expectedErr, "errors should equal the expected value")
|
||||
require.Equal(t, got, tt.expected, "events should equal the expected value")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package bencode
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var unmarshalTests = []struct {
|
||||
|
@ -25,8 +25,8 @@ var unmarshalTests = []struct {
|
|||
func TestUnmarshal(t *testing.T) {
|
||||
for _, tt := range unmarshalTests {
|
||||
got, err := Unmarshal([]byte(tt.input))
|
||||
assert.Nil(t, err, "unmarshal should not fail")
|
||||
assert.Equal(t, got, tt.expected, "unmarshalled values should match the expected results")
|
||||
require.Nil(t, err, "unmarshal should not fail")
|
||||
require.Equal(t, got, tt.expected, "unmarshalled values should match the expected results")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ func TestUnmarshalLarge(t *testing.T) {
|
|||
dec := NewDecoder(&bufferLoop{string(buf)})
|
||||
|
||||
got, err := dec.Decode()
|
||||
assert.Nil(t, err, "decode should not fail")
|
||||
assert.Equal(t, got, data, "encoding and decoding should equal the original value")
|
||||
require.Nil(t, err, "decode should not fail")
|
||||
require.Equal(t, got, data, "encoding and decoding should equal the original value")
|
||||
}
|
||||
|
||||
func BenchmarkUnmarshalLarge(b *testing.B) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var marshalTests = []struct {
|
||||
|
@ -37,8 +37,8 @@ var marshalTests = []struct {
|
|||
func TestMarshal(t *testing.T) {
|
||||
for _, test := range marshalTests {
|
||||
got, err := Marshal(test.input)
|
||||
assert.Nil(t, err, "marshal should not fail")
|
||||
assert.Contains(t, test.expected, string(got), "the marshaled result should be one of the expected permutations")
|
||||
require.Nil(t, err, "marshal should not fail")
|
||||
require.Contains(t, test.expected, string(got), "the marshaled result should be one of the expected permutations")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/chihaya/chihaya/bittorrent"
|
||||
)
|
||||
|
@ -20,14 +20,14 @@ func TestWriteError(t *testing.T) {
|
|||
for _, tt := range table {
|
||||
r := httptest.NewRecorder()
|
||||
err := WriteError(r, bittorrent.ClientError(tt.reason))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, r.Body.String(), tt.expected)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, r.Body.String(), tt.expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteStatus(t *testing.T) {
|
||||
r := httptest.NewRecorder()
|
||||
err := WriteError(r, bittorrent.ClientError("something is missing"))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, r.Body.String(), "d14:failure reason20:something is missinge")
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, r.Body.String(), "d14:failure reason20:something is missinge")
|
||||
}
|
||||
|
|
10
glide.lock
generated
10
glide.lock
generated
|
@ -1,5 +1,5 @@
|
|||
hash: a80b47d15d38444cacc1a086a04a567deb60266887de142074791bf75703f05e
|
||||
updated: 2017-01-26T10:10:57.486607918+01:00
|
||||
hash: 5d8b4db88e29a7095440707b96e55cafed00fd98a32293b4b54950797a54f9bc
|
||||
updated: 2017-02-15T00:55:54.619709972-05:00
|
||||
imports:
|
||||
- name: github.com/beorn7/perks
|
||||
version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
|
||||
|
@ -46,13 +46,13 @@ imports:
|
|||
- name: github.com/prometheus/procfs
|
||||
version: fcdb11ccb4389efb1b210b7ffb623ab71c5fdd60
|
||||
- name: github.com/SermoDigital/jose
|
||||
version: 389fea327ef076853db8fae03a0f38e30e6092ab
|
||||
version: f6df55f235c24f236d11dbcf665249a59ac2021f
|
||||
subpackages:
|
||||
- crypto
|
||||
- jws
|
||||
- jwt
|
||||
- name: github.com/Sirupsen/logrus
|
||||
version: 4b6ea7319e214d98c938f12692336f7ca9348d6b
|
||||
version: c078b1e43f58d563c74cebe63c85789e76ddb627
|
||||
- name: github.com/spf13/cobra
|
||||
version: 0f056af21f5f368e5b0646079d0094a2c64150f7
|
||||
- name: github.com/spf13/pflag
|
||||
|
@ -63,7 +63,7 @@ imports:
|
|||
- assert
|
||||
- require
|
||||
- name: github.com/tylerb/graceful
|
||||
version: 0e9129e9c6d47da90dc0c188b26bd7bb1dab53cd
|
||||
version: 4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb
|
||||
- name: golang.org/x/sys
|
||||
version: d75a52659825e75fff6158388dddc6a5b04f9ba5
|
||||
subpackages:
|
||||
|
|
20
glide.yaml
20
glide.yaml
|
@ -1,26 +1,26 @@
|
|||
package: github.com/chihaya/chihaya
|
||||
import:
|
||||
- package: github.com/SermoDigital/jose
|
||||
version: ~1.0.0
|
||||
version: ^1.1.0
|
||||
subpackages:
|
||||
- crypto
|
||||
- jws
|
||||
- jwt
|
||||
- package: github.com/Sirupsen/logrus
|
||||
version: ~0.10.0
|
||||
version: ^0.11.2
|
||||
- package: github.com/julienschmidt/httprouter
|
||||
version: ~1.1.0
|
||||
version: ^1.1.0
|
||||
- package: github.com/mendsley/gojwk
|
||||
- package: github.com/minio/sha256-simd
|
||||
- package: github.com/prometheus/client_golang
|
||||
version: ~0.8.0
|
||||
version: ^0.8.0
|
||||
subpackages:
|
||||
- prometheus
|
||||
- package: github.com/spf13/cobra
|
||||
- package: github.com/tylerb/graceful
|
||||
version: ~1.2.13
|
||||
- package: gopkg.in/yaml.v2
|
||||
- package: github.com/minio/sha256-simd
|
||||
testImport:
|
||||
- package: github.com/stretchr/testify
|
||||
version: ^1.1.4
|
||||
subpackages:
|
||||
- assert
|
||||
- require
|
||||
- package: github.com/tylerb/graceful
|
||||
version: ^1.2.15
|
||||
- package: gopkg.in/yaml.v2
|
||||
|
|
Loading…
Reference in a new issue