mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
100 lines
2.8 KiB
Go
100 lines
2.8 KiB
Go
package index
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestTimeFrame(t *testing.T) {
|
|
|
|
Convey("Test ID", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
x, _ := time.Parse(shortForm, "2014-01-01 10:03")
|
|
fmt.Println(x)
|
|
|
|
m := GetTimeIds(uint64(1), x, YMDH)
|
|
spew.Dump(m)
|
|
So(1, ShouldEqual, 1)
|
|
})
|
|
Convey("Test 1H", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 10:03")
|
|
t2, _ := time.Parse(shortForm, "2014-01-02 11:03")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 1)
|
|
})
|
|
Convey("Test 2H", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 10:03")
|
|
t2, _ := time.Parse(shortForm, "2014-01-02 12:03")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 2)
|
|
})
|
|
|
|
Convey("Test 24H", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 12:03")
|
|
t2, _ := time.Parse(shortForm, "2014-01-03 12:03")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 24)
|
|
})
|
|
Convey("Test 1D", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 00:00")
|
|
t2, _ := time.Parse(shortForm, "2014-01-03 00:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 1)
|
|
})
|
|
|
|
Convey("Test 1D1H", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 00:00")
|
|
t2, _ := time.Parse(shortForm, "2014-01-03 01:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 2)
|
|
})
|
|
|
|
Convey("Test 1H1D", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 23:00")
|
|
t2, _ := time.Parse(shortForm, "2014-01-04 00:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 2)
|
|
})
|
|
|
|
Convey("Test 1H1D1H", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-02 23:00")
|
|
t2, _ := time.Parse(shortForm, "2014-01-04 01:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 3)
|
|
})
|
|
|
|
Convey("Test 1Y", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-01 00:00")
|
|
t2, _ := time.Parse(shortForm, "2015-01-01 00:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 1)
|
|
})
|
|
Convey("Test 1H1D1M", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-30 23:00")
|
|
t2, _ := time.Parse(shortForm, "2014-03-01 00:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 3)
|
|
})
|
|
|
|
Convey("Test 1H1D1MD1H1", t, func() {
|
|
const shortForm = "2006-01-02 15:04"
|
|
t1, _ := time.Parse(shortForm, "2014-01-30 23:00")
|
|
t2, _ := time.Parse(shortForm, "2014-03-02 01:00")
|
|
m := GetRange(t1, t2, uint64(1))
|
|
So(len(m), ShouldEqual, 5)
|
|
})
|
|
|
|
}
|