瀏覽代碼

added marker for send/receive state check

master
Patrick Peng Sun 8 年之前
父節點
當前提交
4bae0f7d8f
共有 2 個檔案被更改,包括 6 行新增0 行删除
  1. +2
    -0
      chatState.go
  2. +4
    -0
      chatState_test.go

+ 2
- 0
chatState.go 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存