Пример #1
0
func populateSampleEpisodes(t *testing.T, name string, count int) (*Series, *Season, []*Episode) {
	series := NewSeries(name)
	if err := database.SaveSeries(series); err != nil {
		t.Errorf("unexpected error: %v", err)
	}

	season, err := NewSeason(series.Id, 1)
	if err != nil {
		t.Errorf("unexpected error: %v", err)
	}

	if err := database.SaveSeason(season); err != nil {
		t.Errorf("unexpected error: %v", err)
	}

	episodes := make([]*Episode, count)
	for i := 0; i < count; i++ {
		e := &Episode{
			Title:        fmt.Sprintf("Episode %d", i),
			SeasonId:     season.Id,
			SeasonNumber: uint64(season.SeasonNumber),
			SeriesId:     series.Id,
		}
		if err := database.SaveEpisode(e); err != nil {
			t.Errorf("unexpected error: %v", err)
		}
		episodes[i] = e
	}

	return series, season, episodes
}
Пример #2
0
// Creates test seasons all belonging to a single series
func (s *SeasonTestSuite) createSeasons(c *C, count int) (*Series, []*Season) {
	series := NewSeries("test series")
	if err := database.SaveSeries(series); err != nil {
		c.Errorf("unexpected error: %v", err)
	}

	seasons := make([]*Season, count)
	for i := 0; i < count; i++ {
		s, err := NewSeason(series.Id, uint64(i+1))
		if err != nil {
			c.Errorf("unexpected error: %v", err)
		}
		if err = database.SaveSeason(s); err != nil {
			c.Errorf("unexpected error: %v", err)
		}
		seasons[i] = s
	}

	return series, seasons
}