func TestContains(t *testing.T) {
	assert.True(t, contains([]string{"a", "b", "c"}, "b"))
	assert.False(t, contains([]string{"a", "b", "c"}, "d"))
	assert.False(t, contains([]string{"a", "b", "c"}, "A"))
	assert.False(t, contains([]string{"a", "b", "c"}, "ab"))
	assert.False(t, contains([]string{}, "d"))
}
func TestConsole_Save(t *testing.T) {
	print("Console.Save\n")
	seedConsole()
	c := gsc(t)
	c.Has = false
	c.HasBox = false
	c.HasManual = false
	c.Rating = 5
	c.Review = "is bad"
	c.Manufacturer = "newman1"
	c.Year = 2000
	c.Want = true
	c.WantGames = true
	err := c.Save()
	if err != nil {
		t.Errorf("c.Save(): %s", err)
	}
	user, err := auth.GetUser(1)
	if err != nil {
		t.Errorf("GetUser(1): %s", err)
	}
	d, err := GetConsole("NES", user)
	if err != nil {
		t.Errorf("GetConsole(NES,user): %s", err)
	}
	assert.False(t, d.Has, "console.Has")
	assert.False(t, d.HasBox, "console.HasBox")
	assert.False(t, d.HasManual, "console.HasManual")
	assert.Equal(t, 5, d.Rating, "console.Rating")
	assert.Equal(t, "is bad", d.Review, "console.Review")
	assert.Equal(t, "newman1", d.Manufacturer, "console.Manufacturer")
	assert.Equal(t, 2000, d.Year, "console.Year")
	assert.Equal(t, true, d.Want, "console.Want")
	assert.Equal(t, true, d.WantGames, "console.Wantgames")
}
func TestNewCommentDeleted(t *testing.T) {
	c, err := NewComment("What is happening here?", "abcdefg", nil, nil).Dematerialize()
	comment := c.(*Comment)
	assert.Nil(t, err)
	assert.NotNil(t, comment)
	assert.False(t, comment.Deleted)
}
func TestGetConsole(t *testing.T) {
	print("GetConsole\n")
	seedConsole()
	user := gu(t)
	c, err := GetConsole("NES", user)
	if err != nil {
		t.Errorf("GetConsole(NES,1): %s", err)
	}
	assert.Equal(t, 1, c.User.ID, "c.UserID")
	assert.True(t, c.Has, "c.Has")
	assert.True(t, c.HasBox, "c.HasBox")
	assert.True(t, c.HasManual, "c.HasManual")
	assert.Equal(t, 3, c.Rating, "c.Rating")
	assert.Equal(t, "is good", c.Review, "c.Review")
	assert.Equal(t, "Nintendo", c.Manufacturer, "c.Manufacturer")
	assert.False(t, c.Want, "c.Want")
	assert.False(t, c.WantGames, "c.WantGames")
}
func TestEntry_MarkUnread(t *testing.T) {
	e := ef()
	err := e.MarkRead()
	assert.Nil(t, err)
	e = ge()
	assert.False(t, e.Unread)
	err = e.MarkUnread()
	assert.Nil(t, err)
	e = ge()
	assert.True(t, e.Unread)
}
func TestSubjectSendingNext(t *testing.T) {
	subject := Subject{}
	next := false

	subject.Subscribe(func(value interface{}) { next = true },
		func() {},
		func(err error) {})

	subject.SendNext(nil)

	assert.True(t, next)
	assert.False(t, subject.IsStopped())
}
Exemple #7
0
func TestGame_Save(t *testing.T) {
	print("Game.Save\n")
	g := gg(t)
	user, err := auth.GetUser(1)
	assert.Nil(t, err, "auth.GetUser(1)")
	g.Name = "GAME TWO"
	g.ConsoleName = "console2"
	g.Has = false
	g.HasBox = false
	g.HasManual = false
	g.Rating = 5
	g.Review = "is bad"
	g.Publisher = "newman1"
	g.Year = 2000
	g.Want = true
	g.EbayPrice = 33.33
	g.EbayUpdated = "2016-06-22T20:41:25.000Z"
	g.EbayEnds = "2917-06-22T20:41:25.000Z"
	g.EbayURL = "http://ebaything.com/myurl"
	err = g.Save()
	assert.Nil(t, err, "g.Save()")
	d, err := GetGame(1, user)
	assert.Nil(t, err, "GetGame(1,user)")
	assert.Equal(t, d.Name, "GAME TWO", "Name")
	assert.False(t, d.Has, "Has")
	assert.Equal(t, d.ConsoleName, "console2", "consoleName")
	assert.False(t, d.HasBox, "HasBox")
	assert.False(t, d.HasManual, "HasManual")
	assert.Equal(t, d.Rating, 5, "Rating")
	assert.Equal(t, d.Review, "is bad", "Review")
	assert.Equal(t, d.Publisher, "newman1", "Publisher")
	assert.Equal(t, d.Year, 2000, "Year")
	assert.Equal(t, d.EbayEnds, "2917-06-22 20:41:25", "EbayEnds")
	assert.Equal(t, d.EbayPrice, 33.33, "EbayPrice")
	assert.Equal(t, d.EbayUpdated, "2016-06-22 20:41:25", "EbayUpdated")
	assert.Equal(t, d.EbayURL, "http://ebaything.com/myurl", "EbayURL")
	assert.Equal(t, true, d.Want, "Want")
}
func TestEntry_Save(t *testing.T) {
	e := ef()
	e.Title = "newtitle"
	e.Link = "newlink"
	e.Marked = "1"
	e.FeedID = 2
	e.Content = template.HTML("newcontent")
	e.Unread = false
	err := e.Save("test")
	assert.Nil(t, err)
	ne := ge()
	assert.Equal(t, "newtitle", ne.Title)
	assert.Equal(t, "newlink", ne.Link)
	assert.Equal(t, "1", ne.Marked)
	assert.Equal(t, 2, ne.FeedID)
	assert.False(t, ne.Unread)
	if ne.Content != "newcontent" {
		t.Errorf("Content != newcontent: %s", ne.Content)
	}
}
func TestEntry_MarkRead(t *testing.T) {
	e := ef()
	err := e.MarkRead()
	assert.Nil(t, err)
	assert.False(t, ge().Unread)
}