| import ( | import ( | ||||
| "encoding/json" | "encoding/json" | ||||
| "log" | |||||
| "testing" | "testing" | ||||
| ) | ) | ||||
| }` | }` | ||||
| s := WechatUserInfo{} | s := WechatUserInfo{} | ||||
| err := json.Unmarshal([]byte(msg), &s) | err := json.Unmarshal([]byte(msg), &s) | ||||
| log.Println(err) | |||||
| AssertEqual(t, err, nil, "decode json should have no error") | |||||
| AssertEqual(t, s.Avatar, "http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0", "Avatar not right") | AssertEqual(t, s.Avatar, "http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0", "Avatar not right") | ||||
| AssertEqual(t, s.Subscribe, int32(1), "subscribe should =1") | AssertEqual(t, s.Subscribe, int32(1), "subscribe should =1") | ||||
| AssertEqual(t, s.OpenID, "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", "OpenID mismatch") | AssertEqual(t, s.OpenID, "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", "OpenID mismatch") |