Merge pull request #424 from daftaupe/torrentapproval_tests

middleware/torrentapproval : make use of ErrTorrentUnapproved
This commit is contained in:
mrd0ll4r 2018-09-21 09:43:37 +02:00 committed by GitHub
commit 7c5f8bf9c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,8 +6,9 @@ import (
"fmt"
"testing"
"github.com/chihaya/chihaya/bittorrent"
"github.com/stretchr/testify/require"
"github.com/chihaya/chihaya/bittorrent"
)
var cases = []struct {
@ -69,9 +70,9 @@ func TestHandleAnnounce(t *testing.T) {
nctx, err := h.HandleAnnounce(ctx, req, resp)
require.Equal(t, ctx, nctx)
if tt.approved == true {
require.Nil(t, err)
require.NotEqual(t, err, ErrTorrentUnapproved)
} else {
require.NotNil(t, err)
require.Equal(t, err, ErrTorrentUnapproved)
}
})
}