コード例 #1
0
ファイル: scanners.go プロジェクト: falahhaprak/rter
func scanUserDirection(direction *data.UserDirection, rows *sql.Rows) error {
	var updateTimeString string

	err := rows.Scan(
		&direction.Username,
		&direction.LockUsername,
		&direction.Command,
		&direction.Heading,
		&direction.Lat,
		&direction.Lng,
		&updateTimeString,
	)

	if err != nil {
		return err
	}

	updateTime, err := time.Parse("2006-01-02 15:04:05", updateTimeString) // this assumes UTC as timezone

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

	direction.UpdateTime = updateTime

	return nil
}
コード例 #2
0
ファイル: crud_test.go プロジェクト: falahhaprak/rter
func TestReadUserDirection(t *testing.T) {
	readDirection := new(data.UserDirection)

	testRead(t, "/users/"+user.Username+"/direction", readDirection)

	readDirection.UpdateTime = direction.UpdateTime // hack

	structJSONCompare(t, direction, readDirection)
}
コード例 #3
0
ファイル: storage_test.go プロジェクト: falahhaprak/rter
func TestSelectUserDirection(t *testing.T) {
	selectedDirection := new(data.UserDirection)
	selectedDirection.Username = user.Username
	err := Select(selectedDirection)

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

	t.Log(selectedDirection.UpdateTime.UTC())
	t.Log(direction.UpdateTime.UTC())

	selectedDirection.UpdateTime = direction.UpdateTime // hack

	structJSONCompare(t, direction, selectedDirection)
}