Browse Source

added marker for send/receive state check

master
Patrick Peng Sun 8 years ago
parent
commit
4bae0f7d8f
2 changed files with 6 additions and 0 deletions
  1. +2
    -0
      chatState.go
  2. +4
    -0
      chatState_test.go

+ 2
- 0
chatState.go View File

Name string `json:"Name"` //state name Name string `json:"Name"` //state name
Expire int32 `json:"Expire"` //unix timestamp when this state expire Expire int32 `json:"Expire"` //unix timestamp when this state expire
Send struct { //anything we need to send? 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 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 Message map[string]string `json:"Message"` //the message to be sent,key value pair to describe the message
} `json:"Send"` } `json:"Send"`


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

+ 4
- 0
chatState_test.go View File

"txt": "What is your date of birth?", "txt": "What is your date of birth?",
"icon": "/mnt/data/abc.jpg"} "icon": "/mnt/data/abc.jpg"}
s.Send.Type = "text" s.Send.Type = "text"
s.Send.Sent = false
s.Receive.Hint = "hint" s.Receive.Hint = "hint"
s.Receive.Received = false
s.Receive.Validator = "validator email" s.Receive.Validator = "validator email"
s.Receive.Message = map[string]string{ s.Receive.Message = map[string]string{
"rtxt": "should be 3 chars at least", "rtxt": "should be 3 chars at least",
AssertEqual(t, m.Name, n.Name, "Name should be equal") AssertEqual(t, m.Name, n.Name, "Name should be equal")
AssertEqual(t, m.Expire, n.Expire, "Expire 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.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["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.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") AssertEqual(t, m.Receive.Message["rtxt"], n.Receive.Message["rtxt"], "Message[rtxt] should be equal")

Loading…
Cancel
Save