소스 검색

update article test to full details

master
Patrick Peng Sun 8 년 전
부모
커밋
9b02b40762
1개의 변경된 파일23개의 추가작업 그리고 12개의 파일을 삭제
  1. +23
    -12
      material_test.go

+ 23
- 12
material_test.go 파일 보기

@@ -87,8 +87,8 @@ func TestUnmarshalNewsList(t *testing.T) {
"news_item": [
{
"title": "新人入会前几周推荐",
"author": "孙鹏",
"digest": "摘要",
"author": "abc",
"digest": "excerpt",
"content": "<p>&nbsp;&nbsp;&nbsp;&nbsp;新人入会,前几周推荐做如下几件事情<\/p><p><img data-s=\"300,640\" data-type=\"jpeg\" data-src=\"http:\/\/mmbiz.qpic.cn\/mmbiz_jpg\/WiaVAicTdo7zMBVOE4QKxFFnFwbnFbyYGUs0YQBiatN97ibIgOWE4picXg49jj1k5TRibswd7DzLC1CCvJco0Kic9T90g\/0?wx_fmt=jpeg\" data-ratio=\"0.9035087719298246\" data-w=\"342\" \/><\/p><p><br \/><\/p>",
"content_source_url": "",
"thumb_media_id": "SCqYVM0F3OSBIqptPWQ5ZjDYlLvKsEtHHaYnHLyXbeM",
@@ -141,23 +141,34 @@ func TestUnmarshalNewsList(t *testing.T) {
//first item
item := r.Items[0]
AssertEqual(t, item.MediaID, "e2iNEiSxCX5TV1WbFd0TQP4_MKtjcY1q-4UPIZFrHhw", "Item[0] media ID wrong")
//AssertEqual(t, item.CreateTime, 1494488254, "Item[0] create time wrong")
AssertEqual(t, item.UpdateTime, 1494488268, "Item[0] update time wrong")
AssertEqual(t, item.Content.CreateTime, 1494488254, "Item[0].Content Create time wrong")
AssertEqual(t, item.Content.UpdateTime, 1494488268, "Item[0].Content Update time wrong")
AssertEqual(t, item.Content.NewsItem[0].Title, "新人入会前几周推荐", "Item[0].Content.NewsItem[0].Title mismatch")
AssertEqual(t, item.Content.NewsItem[0].Author, "abc", "Item[0].Content.NewsItem[0].Author should be abc")
AssertEqual(t, item.Content.NewsItem[0].Digest, "excerpt", "Item[0].Content.NewsItem[0].Digest shold be excerpt")
AssertEqual(t, item.Content.NewsItem[0].Content, "<p>&nbsp;&nbsp;&nbsp;&nbsp;新人入会,前几周推荐做如下几件事情</p><p><img data-s=\"300,640\" data-type=\"jpeg\" data-src=\"http://mmbiz.qpic.cn/mmbiz_jpg/WiaVAicTdo7zMBVOE4QKxFFnFwbnFbyYGUs0YQBiatN97ibIgOWE4picXg49jj1k5TRibswd7DzLC1CCvJco0Kic9T90g/0?wx_fmt=jpeg\" data-ratio=\"0.9035087719298246\" data-w=\"342\" /></p><p><br /></p>", "Item[0].Content.NewsItem[0].Content wrong")
AssertEqual(t, item.Content.NewsItem[0].ContentSourceURL, "", "Item[0].Content.NewsItem[0].ContentSourceURL wrong")
AssertEqual(t, item.Content.NewsItem[0].ThumbMediaID, "SCqYVM0F3OSBIqptPWQ5ZjDYlLvKsEtHHaYnHLyXbeM", "Item[0].Content.NewsItem[0].ThumbMediaID wrong")
AssertEqual(t, item.Content.NewsItem[0].ShowCoverPic, 0, "Item[0].Content.NewsItem[0].ShowCoverPIC should be 0")
AssertEqual(t, item.Content.NewsItem[0].URL, "http://mp.weixin.qq.com/s?__biz=MzUxMDAzNDAwMA==&mid=100000008&idx=1&sn=cbfd3f5f5367ca67f9a1184eb394f788&chksm=790868374e7fe121ac5e1d27f6d082c3f8e8033eb4e7158615d0a69dc76ac2971e5650b28fac#rd", "Article URL is not right")
AssertEqual(t, item.Content.NewsItem[0].ThumbURL, "http://mmbiz.qpic.cn/mmbiz_jpg/WiaVAicTdo7zMBVOE4QKxFFnFwbnFbyYGUs0YQBiatN97ibIgOWE4picXg49jj1k5TRibswd7DzLC1CCvJco0Kic9T90g/0?wx_fmt=jpeg", "Article Thumb URL wrong")
AssertEqual(t, item.Content.NewsItem[0].NeedOpenComment, 0, "Need Open Comment should be 0")
AssertEqual(t, item.Content.NewsItem[0].OnlyFansCanComment, 0, "OnlyFansCanComment should be 0")

//second item
item = r.Items[1]
AssertEqual(t, item.MediaID, "e2iNEiSxCX5TV1WbFd0TQMqvVrqFDbDOacdjgQ-OAuE", "Item[1] media ID wrong")
//AssertEqual(t, item.CreateTime, 1494488254, "Item[1] create time wrong")
AssertEqual(t, item.UpdateTime, 1492696243, "Item[1] update time wrong")
AssertEqual(t, item.Content.CreateTime, 1492696196, "Item[1] update time wrong")
AssertEqual(t, item.Content.UpdateTime, 1492696243, "Item[1] update time wrong")
AssertEqual(t, item.Content.NewsItem[0].Title, "测试消息", "Item[1] update time wrong")
AssertEqual(t, item.Content.NewsItem[0].Author, "孙鹏", "Item[1] update time wrong")
AssertEqual(t, item.Content.NewsItem[0].Digest, "加入校友会", "Item[1] update time wrong")
AssertEqual(t, item.Content.CreateTime, 1492696196, "Item[1].Content.CreateTime wrong")
AssertEqual(t, item.Content.UpdateTime, 1492696243, "Item[1].Content.Update time wrong")
AssertEqual(t, item.Content.NewsItem[0].Title, "测试消息", "Item[1].NewsItem[0].Title wrong")
AssertEqual(t, item.Content.NewsItem[0].Author, "孙鹏", "Item[1].NewsItem[0].Author wrong")
AssertEqual(t, item.Content.NewsItem[0].Digest, "加入校友会", "Item[1].NewsItem[0].Digest wrong")
AssertEqual(t, item.Content.NewsItem[0].Content, "<p>加入校友会</p><p><img data-s=\"300,640\" data-type=\"png\" data-src=\"http://mmbiz.qpic.cn/mmbiz_png/WiaVAicTdo7zP8HtgLHegmr32SLxcGv0wjQ1pic9oePDgk6XUhDz6xfhicmiaq4ITfibtfPOsulOMD7icIfSicibd8By3Tw/0?wx_fmt=png\" data-ratio=\"0.6765327695560254\" data-w=\"946\" /></p><p><br /></p>", "article content wrong")
AssertEqual(t, item.Content.NewsItem[0].ContentSourceURL, "http://www.hitxy.org.au/join", "Item[1] update time wrong")
AssertEqual(t, item.Content.NewsItem[0].ThumbMediaID, "SCqYVM0F3OSBIqptPWQ5ZjDYlLvKsEtHHaYnHLyXbeM", "Item[1] update time wrong")
AssertEqual(t, item.Content.NewsItem[0].ShowCoverPic, 0, "Item[1] update time wrong")
AssertEqual(t, item.Content.NewsItem[0].ContentSourceURL, "http://www.hitxy.org.au/join", "Item[1].NewsItem[0].ContentSourceURL wrong")
AssertEqual(t, item.Content.NewsItem[0].ThumbMediaID, "SCqYVM0F3OSBIqptPWQ5ZjDYlLvKsEtHHaYnHLyXbeM", "Item[1].NewsItem[0].ThumbMediaID wrong")
AssertEqual(t, item.Content.NewsItem[0].ShowCoverPic, 0, "Item[1].NewsItem[0].ShowCoverPic wrong")
AssertEqual(t, item.Content.NewsItem[0].URL, "http://mp.weixin.qq.com/s?__biz=MzUxMDAzNDAwMA==&mid=100000002&idx=1&sn=723bf16b52f88345e5a73ccde1c79bdb&chksm=7908683d4e7fe12bcaefa9c563809db5546ab97af7184ec648f20930fab5c1d95ee825409c0d#rd", "Article URL is not right")
AssertEqual(t, item.Content.NewsItem[0].ThumbURL, "http://mmbiz.qpic.cn/mmbiz_png/WiaVAicTdo7zP8HtgLHegmr32SLxcGv0wjQ1pic9oePDgk6XUhDz6xfhicmiaq4ITfibtfPOsulOMD7icIfSicibd8By3Tw/0?wx_fmt=png", "Article Thumb URL wrong")
AssertEqual(t, item.Content.NewsItem[0].NeedOpenComment, 0, "Need Open Comment should be 0")

Loading…
취소
저장