2016-01-25 06:41:39 +01:00
|
|
|
// Copyright 2016 The Chihaya Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by the BSD 2-Clause license,
|
|
|
|
// which can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNew(t *testing.T) {
|
|
|
|
var table = []struct {
|
|
|
|
data string
|
2016-02-16 01:49:25 +01:00
|
|
|
expected Event
|
2016-01-25 06:41:39 +01:00
|
|
|
expectedErr error
|
|
|
|
}{
|
2016-02-17 23:39:21 +01:00
|
|
|
{"", None, nil},
|
2016-01-25 06:41:39 +01:00
|
|
|
{"NONE", None, nil},
|
|
|
|
{"none", None, nil},
|
|
|
|
{"started", Started, nil},
|
|
|
|
{"stopped", Stopped, nil},
|
|
|
|
{"completed", Completed, nil},
|
|
|
|
{"notAnEvent", None, ErrUnknownEvent},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tt := range table {
|
|
|
|
got, err := New(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")
|
|
|
|
}
|
|
|
|
}
|