Exemplo n.º 1
0
func TestMetaEncode(t *testing.T) {
	at := model.Time{Time: time.Date(2011, 2, 3, 4, 5, 6, 0, time.UTC)}
	tag := model.Tag{
		Name: "Go",
	}
	tags := model.Tags{tag}
	meta := model.Meta{
		ID:        "4bd431809afb1bb99e4f",
		URL:       "https://qiita.com/yaotti/items/4bd431809afb1bb99e4f",
		CreatedAt: at,
		UpdatedAt: at,
		Private:   true,
		Coediting: true,
		Tags:      tags,
		Team: &model.Team{
			Active: true,
			ID:     "increments",
			Name:   "Increments Inc.",
		},
	}
	expected := `id: 4bd431809afb1bb99e4f
url: https://qiita.com/yaotti/items/4bd431809afb1bb99e4f
created_at: 2011-02-03T13:05:06+09:00
updated_at: 2011-02-03T13:05:06+09:00
private: true
coediting: true
tags:
- Go
team:
  active: true
  id: increments
  name: Increments Inc.`
	actual := meta.Encode()
	if actual != expected {
		t.Errorf("wrong string:\n%s", testutil.Diff(expected, actual))
	}
}