Merge pull request #296 from jzelinskie/require-all

Replace last usage of assert with require
This commit is contained in:
Jimmy Zelinskie 2017-02-15 14:05:50 -05:00 committed by GitHub
commit b028a36424
6 changed files with 31 additions and 31 deletions

View file

@ -3,7 +3,7 @@ package bittorrent
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"
) )
func TestNew(t *testing.T) { func TestNew(t *testing.T) {
@ -23,7 +23,7 @@ func TestNew(t *testing.T) {
for _, tt := range table { for _, tt := range table {
got, err := NewEvent(tt.data) got, err := NewEvent(tt.data)
assert.Equal(t, err, tt.expectedErr, "errors should equal the expected value") require.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, got, tt.expected, "events should equal the expected value")
} }
} }

View file

@ -3,7 +3,7 @@ package bencode
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"
) )
var unmarshalTests = []struct { var unmarshalTests = []struct {
@ -25,8 +25,8 @@ var unmarshalTests = []struct {
func TestUnmarshal(t *testing.T) { func TestUnmarshal(t *testing.T) {
for _, tt := range unmarshalTests { for _, tt := range unmarshalTests {
got, err := Unmarshal([]byte(tt.input)) got, err := Unmarshal([]byte(tt.input))
assert.Nil(t, err, "unmarshal should not fail") require.Nil(t, err, "unmarshal should not fail")
assert.Equal(t, got, tt.expected, "unmarshalled values should match the expected results") 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)}) dec := NewDecoder(&bufferLoop{string(buf)})
got, err := dec.Decode() got, err := dec.Decode()
assert.Nil(t, err, "decode should not fail") require.Nil(t, err, "decode should not fail")
assert.Equal(t, got, data, "encoding and decoding should equal the original value") require.Equal(t, got, data, "encoding and decoding should equal the original value")
} }
func BenchmarkUnmarshalLarge(b *testing.B) { func BenchmarkUnmarshalLarge(b *testing.B) {

View file

@ -5,7 +5,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"
) )
var marshalTests = []struct { var marshalTests = []struct {
@ -37,8 +37,8 @@ var marshalTests = []struct {
func TestMarshal(t *testing.T) { func TestMarshal(t *testing.T) {
for _, test := range marshalTests { for _, test := range marshalTests {
got, err := Marshal(test.input) got, err := Marshal(test.input)
assert.Nil(t, err, "marshal should not fail") require.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.Contains(t, test.expected, string(got), "the marshaled result should be one of the expected permutations")
} }
} }

View file

@ -4,7 +4,7 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"
"github.com/chihaya/chihaya/bittorrent" "github.com/chihaya/chihaya/bittorrent"
) )
@ -20,14 +20,14 @@ func TestWriteError(t *testing.T) {
for _, tt := range table { for _, tt := range table {
r := httptest.NewRecorder() r := httptest.NewRecorder()
err := WriteError(r, bittorrent.ClientError(tt.reason)) err := WriteError(r, bittorrent.ClientError(tt.reason))
assert.Nil(t, err) require.Nil(t, err)
assert.Equal(t, r.Body.String(), tt.expected) require.Equal(t, r.Body.String(), tt.expected)
} }
} }
func TestWriteStatus(t *testing.T) { func TestWriteStatus(t *testing.T) {
r := httptest.NewRecorder() r := httptest.NewRecorder()
err := WriteError(r, bittorrent.ClientError("something is missing")) err := WriteError(r, bittorrent.ClientError("something is missing"))
assert.Nil(t, err) require.Nil(t, err)
assert.Equal(t, r.Body.String(), "d14:failure reason20:something is missinge") require.Equal(t, r.Body.String(), "d14:failure reason20:something is missinge")
} }

10
glide.lock generated
View file

@ -1,5 +1,5 @@
hash: a80b47d15d38444cacc1a086a04a567deb60266887de142074791bf75703f05e hash: 5d8b4db88e29a7095440707b96e55cafed00fd98a32293b4b54950797a54f9bc
updated: 2017-01-26T10:10:57.486607918+01:00 updated: 2017-02-15T00:55:54.619709972-05:00
imports: imports:
- name: github.com/beorn7/perks - name: github.com/beorn7/perks
version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
@ -46,13 +46,13 @@ imports:
- name: github.com/prometheus/procfs - name: github.com/prometheus/procfs
version: fcdb11ccb4389efb1b210b7ffb623ab71c5fdd60 version: fcdb11ccb4389efb1b210b7ffb623ab71c5fdd60
- name: github.com/SermoDigital/jose - name: github.com/SermoDigital/jose
version: 389fea327ef076853db8fae03a0f38e30e6092ab version: f6df55f235c24f236d11dbcf665249a59ac2021f
subpackages: subpackages:
- crypto - crypto
- jws - jws
- jwt - jwt
- name: github.com/Sirupsen/logrus - name: github.com/Sirupsen/logrus
version: 4b6ea7319e214d98c938f12692336f7ca9348d6b version: c078b1e43f58d563c74cebe63c85789e76ddb627
- name: github.com/spf13/cobra - name: github.com/spf13/cobra
version: 0f056af21f5f368e5b0646079d0094a2c64150f7 version: 0f056af21f5f368e5b0646079d0094a2c64150f7
- name: github.com/spf13/pflag - name: github.com/spf13/pflag
@ -63,7 +63,7 @@ imports:
- assert - assert
- require - require
- name: github.com/tylerb/graceful - name: github.com/tylerb/graceful
version: 0e9129e9c6d47da90dc0c188b26bd7bb1dab53cd version: 4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb
- name: golang.org/x/sys - name: golang.org/x/sys
version: d75a52659825e75fff6158388dddc6a5b04f9ba5 version: d75a52659825e75fff6158388dddc6a5b04f9ba5
subpackages: subpackages:

View file

@ -1,26 +1,26 @@
package: github.com/chihaya/chihaya package: github.com/chihaya/chihaya
import: import:
- package: github.com/SermoDigital/jose - package: github.com/SermoDigital/jose
version: ~1.0.0 version: ^1.1.0
subpackages: subpackages:
- crypto - crypto
- jws - jws
- jwt - jwt
- package: github.com/Sirupsen/logrus - package: github.com/Sirupsen/logrus
version: ~0.10.0 version: ^0.11.2
- package: github.com/julienschmidt/httprouter - package: github.com/julienschmidt/httprouter
version: ~1.1.0 version: ^1.1.0
- package: github.com/mendsley/gojwk - package: github.com/mendsley/gojwk
- package: github.com/minio/sha256-simd
- package: github.com/prometheus/client_golang - package: github.com/prometheus/client_golang
version: ~0.8.0 version: ^0.8.0
subpackages: subpackages:
- prometheus - prometheus
- package: github.com/spf13/cobra - 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 - package: github.com/stretchr/testify
version: ^1.1.4
subpackages: subpackages:
- assert - require
- package: github.com/tylerb/graceful
version: ^1.2.15
- package: gopkg.in/yaml.v2