| @@ -2,6 +2,7 @@ package main | |||
| import ( | |||
| "encoding/json" | |||
| "log" | |||
| "testing" | |||
| ) | |||
| @@ -49,7 +50,7 @@ func TestDecodeSubscribeJson(t *testing.T) { | |||
| } | |||
| func TestRegisterNewUser(t *testing.T) { | |||
| msg := ` | |||
| { | |||
| "subscribe": 1, | |||
| @@ -74,5 +75,13 @@ func TestRegisterNewUser(t *testing.T) { | |||
| in.header.FromUserName = "abc" | |||
| s := WechatUserInfo{} | |||
| json.Unmarshal([]byte(msg), &s) | |||
| s.registerNewUserWithInfo(in) | |||
| newuser, err := s.registerNewUserWithInfo(in) | |||
| AssertEqual(t, err, nil, "should be successfully added new user") | |||
| AssertEqual(t, newuser.WechatHitxyID, in.header.FromUserName, "wechat_hitxy_id mismatch") | |||
| log.Printf("created temp Lead %s ", newuser.ID) | |||
| deleted, err := crmDeleteEntity("Lead", newuser.ID) | |||
| AssertEqual(t, err, nil, "should be successfully cleanup test record") | |||
| AssertEqual(t, deleted, true, "deleted should be true ") | |||
| log.Printf("deleted temp Lead %s ", newuser.ID) | |||
| } | |||