Beispiel #1
0
func scanTermRanking(ranking *data.TermRanking, rows *sql.Rows) error {
	var updateTimeString string

	err := rows.Scan(
		&ranking.Term,
		&ranking.Ranking,
		&updateTimeString,
	)

	if err != nil {
		return err
	}

	// TODO: this is a hacky fix for null times
	if updateTimeString == "0000-00-00 00:00:00" {
		updateTimeString = "0001-01-01 00:00:00"
	}
	updateTime, err := time.Parse("2006-01-02 15:04:05", updateTimeString) // this assumes UTC as timezone

	if err != nil {
		log.Println("TermRanking scanner failed to parse time.")
		return err
	}

	ranking.UpdateTime = updateTime

	return nil
}
Beispiel #2
0
func TestReadTermRanking(t *testing.T) {
	readRanking := new(data.TermRanking)

	testRead(t, "/taxonomy/"+term.Term+"/ranking", readRanking)

	readRanking.UpdateTime = ranking.UpdateTime
	structJSONCompare(t, ranking, readRanking)
}
Beispiel #3
0
func TestSelectTermRanking(t *testing.T) {
	selectedRanking := new(data.TermRanking)
	selectedRanking.Term = ranking.Term
	err := Select(selectedRanking)

	if err != nil {
		t.Error(err)
	}

	t.Log(ranking.UpdateTime.UTC())
	t.Log(selectedRanking.UpdateTime.UTC())

	selectedRanking.UpdateTime = ranking.UpdateTime

	structJSONCompare(t, ranking, selectedRanking)
}