2016-08-03 03:11:52 -04:00
|
|
|
package bittorrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-02-15 00:57:36 -05:00
|
|
|
"github.com/stretchr/testify/require"
|
2016-08-03 03:11:52 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNew(t *testing.T) {
|
|
|
|
var table = []struct {
|
|
|
|
data string
|
|
|
|
expected Event
|
|
|
|
expectedErr error
|
|
|
|
}{
|
|
|
|
{"", None, nil},
|
|
|
|
{"NONE", None, nil},
|
|
|
|
{"none", None, nil},
|
|
|
|
{"started", Started, nil},
|
|
|
|
{"stopped", Stopped, nil},
|
|
|
|
{"completed", Completed, nil},
|
|
|
|
{"notAnEvent", None, ErrUnknownEvent},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tt := range table {
|
|
|
|
got, err := NewEvent(tt.data)
|
2017-02-15 00:57:36 -05:00
|
|
|
require.Equal(t, err, tt.expectedErr, "errors should equal the expected value")
|
|
|
|
require.Equal(t, got, tt.expected, "events should equal the expected value")
|
2016-08-03 03:11:52 -04:00
|
|
|
}
|
|
|
|
}
|