Пример #1
0
func TestValidateUserName(t *testing.T) {
	var err error
	now := strconv.FormatInt(time.Now().Unix(), 10)

	track := Track{
		Id:           "123",
		Genre:        "Genre",
		Title:        "Title",
		Description:  "Description",
		Url:          "Url",
		ImageUrl:     "ImageUrl",
		UserImageUrl: "UserImageUrl",
		UserUrl:      "UserUrl",
		UserName:     "",
		Type:         "soundcloud",
		CreatedAt:    now,
	}

	err = track.Validate()
	if err == nil {
		t.Error("Track#Validate() should return error if Track#UserName is empty")
		return
	}

	test_helpers.AssertEqual(t, "This item doesn't have UserName", err.Error())
}
Пример #2
0
func TestMappingJsonToItem(t *testing.T) {
	var item Item
	err := json.Unmarshal(itemJson, &item)

	if err != nil {
		panic(err)
	}

	test_helpers.AssertEqual(t, 93919708, item.Id)
	test_helpers.AssertEqual(t, "Hop.Hip", item.Genre)
	test_helpers.AssertEqual(t, "ignorntsht[TWRK]", item.Title)
	test_helpers.AssertEqual(t, "http://soundcloud.com/knxwledge/ignorntsht-twrk", item.Url)
	test_helpers.AssertEqual(t, "http://gloof.bandcamp.com/album/wraptaypes-prt-5", item.Description)
	test_helpers.AssertEqual(t, "http://i1.sndcdn.com/artworks-000048980129-sa1mue-large.jpg?5ffe3cd", item.ImageUrl)
	test_helpers.AssertEqual(t, "http://i1.sndcdn.com/avatars-000043150214-63rk2k-large.jpg?5ffe3cd", item.User.ImageUrl)
	test_helpers.AssertEqual(t, "http://soundcloud.com/knxwledge", item.User.Url)
}
Пример #3
0
func TestCurrentTrackValidate(t *testing.T) {
	var err error
	now := strconv.FormatInt(time.Now().Unix(), 10)

	currentTrack := CurrentTrack{
		TrackId:   "",
		StartedAt: now,
	}

	err = currentTrack.Validate()
	if err == nil {
		t.Error("CurrentTrack#Validate() should return error if CurrentTrack#TrackId is empty")
		return
	}

	test_helpers.AssertEqual(t, "Current track should have track ID", err.Error())
}