-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratchub_test.go
More file actions
42 lines (36 loc) · 924 Bytes
/
scratchub_test.go
File metadata and controls
42 lines (36 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package scratchgo
import (
"fmt"
. "github.com/r7kamura/gospel"
"testing"
)
type ErrorNotExistPort struct{}
func (self ErrorNotExistPort) Action(msg *Message) error {
return nil
}
type ErrorExistPort struct{}
func (self ErrorExistPort) Action(msg *Message) error {
return fmt.Errorf("ErrorExistPort")
}
func TestScaratchub(t *testing.T) {
Describe(t, "Scratchub TestCase", func() {
Context("create hub", func() {
It("create new hub.", func() {
actual := Newhub([]Port{ErrorNotExistPort{}})
Expect(actual).To(Exist)
})
})
Context("run func Action.", func() {
It("error not exist", func() {
actual := Newhub([]Port{ErrorNotExistPort{}})
err := actual.Action(&Message{})
Expect(err).To(NotExist)
})
It("error exist", func() {
actual := Newhub([]Port{ErrorExistPort{}, ErrorNotExistPort{}})
err := actual.Action(&Message{})
Expect(err).To(Exist)
})
})
})
}