func checkTimeSeries(t *testing.T, got *ts.TimeSeries, exp *TestSeries) {
	if got == nil {
		t.Errorf("FAIL(TimeSeries): can't be nil")
		return
	}
	if exp == nil {
		t.Errorf("FAIL(TimeSeries): can't be nil")
		return
	}
	checkKey(t, got.Key(), exp.Key)
	checkStart(t, got.Start(), exp.Start)
	checkEnd(t, got.End(), exp.End)
	checkStep(t, got.Step(), exp.Step)
	checkData(t, got.Data(), exp.Data)
}
Ejemplo n.º 2
0
func timeString(ts *ts.TimeSeries) (string, error) {
	s := bytes.NewBufferString("[ 'x', ")

	cursor := ts.Start()
	step := ts.Step()
	for _, _ = range ts.Data() {
		if err := s.WriteByte('\''); err != nil {
			return "", err
		}
		if _, err := s.WriteString(cursor.Format("20060102 15:04:05")); err != nil {
			return "", err
		}
		if _, err := s.WriteString("',"); err != nil {
			return "", err
		}
		cursor = cursor.Add(step)
	}
	if s.Len() > 0 {
		s.Truncate(s.Len() - 1)
	}
	if err := s.WriteByte(']'); err != nil {
		return "", err
	}
	return s.String(), nil
}