-
Notifications
You must be signed in to change notification settings - Fork 16
/
input_test.go
89 lines (79 loc) · 2.15 KB
/
input_test.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package sarah
import (
"testing"
"time"
)
type DummyInput struct {
SenderKeyValue string
MessageValue string
SentAtValue time.Time
ReplyToValue OutputDestination
}
func (i *DummyInput) SenderKey() string {
return i.SenderKeyValue
}
func (i *DummyInput) Message() string {
return i.MessageValue
}
func (i *DummyInput) SentAt() time.Time {
return i.SentAtValue
}
func (i *DummyInput) ReplyTo() OutputDestination {
return i.ReplyToValue
}
func TestNewHelpInput(t *testing.T) {
senderKey := "sender"
message := "Hello, 世界."
sentAt := time.Now()
dest := "100 N University Dr Edmond, OK"
input := &DummyInput{
SenderKeyValue: senderKey,
MessageValue: message,
SentAtValue: sentAt,
ReplyToValue: dest,
}
helpInput := NewHelpInput(input)
if helpInput.SenderKey() != senderKey {
t.Errorf("Expected sender key was not returned: %s.", senderKey)
}
if helpInput.Message() != message {
t.Errorf("Expected message was not returned: %s.", message)
}
if helpInput.SentAt() != sentAt {
t.Errorf("Expected time was not returned: %s.", sentAt.String())
}
if helpInput.ReplyTo() != dest {
t.Errorf("Expected reply destination was not returned: %s.", dest)
}
if helpInput.OriginalInput != input {
t.Errorf("Original Input value is not set: %#v", helpInput.OriginalInput)
}
}
func TestNewAbortInput(t *testing.T) {
senderKey := "sender"
message := "Hello, 世界."
sentAt := time.Now()
dest := "100 N University Dr Edmond, OK"
input := &DummyInput{
SenderKeyValue: senderKey,
MessageValue: message,
SentAtValue: sentAt,
ReplyToValue: dest,
}
abortInput := NewAbortInput(input)
if abortInput.SenderKey() != senderKey {
t.Errorf("Expected sender key was not returned: %s.", senderKey)
}
if abortInput.Message() != message {
t.Errorf("Expected message was not returned: %s.", message)
}
if abortInput.SentAt() != sentAt {
t.Errorf("Expected time was not returned: %s.", sentAt.String())
}
if abortInput.ReplyTo() != dest {
t.Errorf("Expected reply destination was not returned: %s.", dest)
}
if abortInput.OriginalInput != input {
t.Errorf("Original Input value is not set: %#v", abortInput.OriginalInput)
}
}