~thrrgilag/woodstock

7a38312e30314c10f6a20a0dd6d7aa5146147059 — Morgan McMillian 2 years ago a066b79
support unknown raw value types
2 files changed, 29 insertions(+), 2 deletions(-)

M objects.go
M posts_test.go
M objects.go => objects.go +3 -2
@@ 259,7 259,8 @@ type Marker struct {
	Name       string `json:"name"`
}

// Raw object definition
type Raw struct {
	Type  string            `json:"type"`
	Value map[string]string `json:"value"`
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

M posts_test.go => posts_test.go +26 -0
@@ 55,6 55,32 @@ func TestLongPost(t *testing.T) {
	time.Sleep(Delay)
}

func TestPhotoPost(t *testing.T) {
	config, err := GetConfig()
	if err != nil {
		t.Error(err)
	}
	text := "I don't always have a slow internet connection."
	client := NewClient(config.ClientID, "")
	client.SetAccessToken(config.AccessToken)
	filevalue := map[string]string{}
	filevalue["file_id"] = "14984"
	filevalue["file_token"] = "5hwO-VFP-IAjai_yq2MwJ3PXvw__D6vr"
	filevalue["format"] = "oembed"
	value := map[string]map[string]string{"+io.pnut.core.file": filevalue}
	var raw []Raw
	raw = append(raw, Raw{Type: "io.pnut.core.oembed", Value: value})
	newpost := NewPost{Text: text, 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 TestGetPost(t *testing.T) {
	config, err := GetConfig()
	if err != nil {