Selaa lähdekoodia

added marker for send/receive state check

master
Patrick Peng Sun 8 vuotta sitten
vanhempi
commit
4bae0f7d8f
2 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. +2
    -0
      chatState.go
  2. +4
    -0
      chatState_test.go

+ 2
- 0
chatState.go Näytä tiedosto

@@ -19,11 +19,13 @@ type chatState struct {
Name string `json:"Name"` //state name
Expire int32 `json:"Expire"` //unix timestamp when this state expire
Send struct { //anything we need to send?
Sent bool `json:"Sent"` //whether the message has been sent or not
Type string `json:"Type"` //what type of message
Message map[string]string `json:"Message"` //the message to be sent,key value pair to describe the message
} `json:"Send"`

Receive struct { //anything we expect to receive
Received bool `json:"Received"` //whether the expected message has been received or not
Validator string `json:"Validator"`
Hint string `json:"Hint"`
Message map[string]string `json:"Message"` //the description for receiving message

+ 4
- 0
chatState_test.go Näytä tiedosto

@@ -14,7 +14,9 @@ func TestChatState(t *testing.T) {
"txt": "What is your date of birth?",
"icon": "/mnt/data/abc.jpg"}
s.Send.Type = "text"
s.Send.Sent = false
s.Receive.Hint = "hint"
s.Receive.Received = false
s.Receive.Validator = "validator email"
s.Receive.Message = map[string]string{
"rtxt": "should be 3 chars at least",
@@ -31,6 +33,8 @@ func TestChatState(t *testing.T) {
AssertEqual(t, m.Name, n.Name, "Name should be equal")
AssertEqual(t, m.Expire, n.Expire, "Expire should be equal")
AssertEqual(t, m.Send.Type, n.Send.Type, "Send.Type should be equal")
AssertEqual(t, m.Receive.Received, false, "Receive.Received should be false")
AssertEqual(t, m.Send.Sent, false, "Send.Sent should be false")
AssertEqual(t, m.Send.Message["txt"], n.Send.Message["txt"], "Message[txt] should be equal")
AssertEqual(t, m.Send.Message["icon"], n.Send.Message["icon"], "Message[icon] should be equal")
AssertEqual(t, m.Receive.Message["rtxt"], n.Receive.Message["rtxt"], "Message[rtxt] should be equal")

Loading…
Peruuta
Tallenna