2016-08-03 09:11:52 +02:00
|
|
|
package bittorrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-02-15 06:57:36 +01:00
|
|
|
"github.com/stretchr/testify/require"
|
2016-08-03 09:11:52 +02: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 06:57:36 +01: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 09:11:52 +02:00
|
|
|
}
|
|
|
|
}
|