From 517fb4044ea9aad21fc0e8a2d794080f758acb12 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 15 Feb 2017 00:57:36 -0500 Subject: [PATCH 1/2] tests: replace last usage of assert with require Fixes #239. --- bittorrent/event_test.go | 6 +++--- frontend/http/bencode/decoder_test.go | 10 +++++----- frontend/http/bencode/encoder_test.go | 6 +++--- frontend/http/writer_test.go | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bittorrent/event_test.go b/bittorrent/event_test.go index 637f69b..2dc3cb7 100644 --- a/bittorrent/event_test.go +++ b/bittorrent/event_test.go @@ -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") } } diff --git a/frontend/http/bencode/decoder_test.go b/frontend/http/bencode/decoder_test.go index 485a47a..781f561 100644 --- a/frontend/http/bencode/decoder_test.go +++ b/frontend/http/bencode/decoder_test.go @@ -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) { diff --git a/frontend/http/bencode/encoder_test.go b/frontend/http/bencode/encoder_test.go index 783032b..e6858b0 100644 --- a/frontend/http/bencode/encoder_test.go +++ b/frontend/http/bencode/encoder_test.go @@ -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") } } diff --git a/frontend/http/writer_test.go b/frontend/http/writer_test.go index fbbb9b7..155f767 100644 --- a/frontend/http/writer_test.go +++ b/frontend/http/writer_test.go @@ -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") } From 03080b39b4f6d64baa4850668982f906ec539304 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 15 Feb 2017 00:58:34 -0500 Subject: [PATCH 2/2] glide: bump + track minor versions --- glide.lock | 10 +++++----- glide.yaml | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/glide.lock b/glide.lock index 2daedc9..7fa4c65 100644 --- a/glide.lock +++ b/glide.lock @@ -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: diff --git a/glide.yaml b/glide.yaml index 2031760..9bad837 100644 --- a/glide.yaml +++ b/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