~thrrgilag/woodstock

344e36d7945527548c2623651d2cb62b421cb71d — Morgan McMillian 1 year, 3 months ago 4440946
Add optional fields to NewPost and test replies
2 files changed, 29 insertions(+), 2 deletions(-)

M posts.go
M posts_test.go
M posts.go => posts.go +6 -2
@@ 26,8 26,12 @@ type ActionsResult struct {
}

type NewPost struct {
	Text string `json:"text"`
	Raw  []Raw  `json:"raw"`
	Text               string `json:"text"`
	ParseLinks         string `json:"entities.parse_links,omitempty"`
	ParseMarkdownLinks string `json:"entities.parse_markdown_links,omitempty"`
	Nsfw               string `json:"is_nsfw,omitempty"`
	Raw                []Raw  `json:"raw"`
	ReplyTo            string `json:"reply_to,omitempty"`
}

// GetPost retrieves a post

M posts_test.go => posts_test.go +23 -0
@@ 28,6 28,29 @@ func TestPost(t *testing.T) {
	time.Sleep(Delay)
}

func TestReplyPost(t *testing.T) {
	config, err := GetConfig()
	if err != nil {
		t.Error(err)
	}
	client := NewClient(config.ClientID, "")
	client.SetAccessToken(config.AccessToken)
	text := "Hello pnut.io reply"
	reply_to := "18813"
	language := map[string]string{"language": "en"}
	var raw []Raw
	raw = append(raw, Raw{Type: "io.pnut.core.language", Value: language})
	newpost := NewPost{Text: text, ReplyTo: reply_to, Raw: raw}
	post, err := client.Post(newpost)
	if err != nil {
		t.Error(err)
	}
	if post.Data.Content.Text != text {
		t.Errorf("Post appears incorrect, got: %s, want: %s", post.Data.Content.Text, text)
	}
	time.Sleep(Delay)
}

func TestLongPost(t *testing.T) {
	config, err := GetConfig()
	if err != nil {