func TestDoVotes(t *testing.T) { userPost, _ := nerdz.NewUserPost(13) votesCount := userPost.VotesCount() votes := *userPost.Votes() t.Logf("user(%d) likes user post(%d)", me.Counter, userPost.Hpid) if _, err := me.Vote(userPost, 1); err != nil { t.Fatalf("User is unable to like user post - %v. %d <= %d", err, votesCount, userPost.VotesCount()) } newVotes := *userPost.Votes() if len(newVotes) <= len(votes) { t.Fatalf("Vote has not beed added, because %d <= %d", len(newVotes), len(votes)) } if _, err := me.Vote(userPost, 0); err != nil || votesCount != userPost.VotesCount() { t.Fatalf("User is unable to remove preference from user post - %v. %d != %d", err, votesCount, userPost.VotesCount()) } projPost, _ := nerdz.NewProjectPost(2) t.Logf("user(%d) likes project post(%d)", me.Counter, projPost.Hpid) if _, err := me.Vote(projPost, 1); err != nil { t.Fatalf("User is unable to like project post - %v", err) } }
func init() { if projectPost, e = nerdz.NewProjectPost(uint64(3)); e != nil { panic(fmt.Sprintf("No error should happen when create existing post, but got: %+v", e)) } if userPost, e = nerdz.NewUserPost(6); e != nil { panic(fmt.Sprintf("No error should happen when create existing post, but got: %+v", e)) } userPost1, _ = nerdz.NewUserPost(20) }
func TestProjectPostBookmark(t *testing.T) { post, _ := nerdz.NewProjectPost(2) t.Logf("User(%d) bookmarkers the project's post(%d) ", me.Counter, post.Hpid) oldNumBookmarks := len(post.NumericBookmarkers()) if _, err := me.Bookmark(post); err != nil { t.Error(err) } if len(post.NumericBookmarkers()) != oldNumBookmarks+1 { t.Error("There isn't a new bookmark for the project's post ", post.Hpid) } }
func TestProjectPostUnbookmark(t *testing.T) { post, _ := nerdz.NewProjectPost(2) t.Logf("User(%d) unbookmarkers the project's post(%d) ", me.Counter, post.Hpid) oldNumBookmarks := len(post.NumericBookmarkers()) if err := me.Unbookmark(post); err != nil { t.Error(err) } if len(post.NumericBookmarkers()) != oldNumBookmarks-1 { t.Error("Bookmark isn't removed for the project ", post.Hpid) } }
func TestDoThumbs(t *testing.T) { userPost, _ := nerdz.NewUserPost(13) t.Logf("user(%d) likes user post(%d)", me.Counter, userPost.Hpid) if err := me.ThumbUp(userPost); err != nil { t.Errorf("User is unable to like user post - %v", err) } projPost, _ := nerdz.NewProjectPost(2) t.Logf("user(%d) likes project post(%d)", me.Counter, projPost.Hpid) if err := me.ThumbUp(projPost); err != nil { t.Errorf("User is unable to like project post - %v", err) } }