Package path refactor.

This commit is contained in:
go-jet 2019-06-21 13:56:57 +02:00
parent 829736279b
commit 83d4c5ad03
72 changed files with 162 additions and 188 deletions

76
expression_old_test.go Normal file
View file

@ -0,0 +1,76 @@
// +build disabled
package jet
import (
"bytes"
"time"
gc "gopkg.in/check.v1"
)
func (s *ExprSuite) TestInterval(c *gc.C) {
testTable := []struct {
interval time.Duration
expected string
expectedErr error
}{
{
interval: 50 * time.Microsecond,
expected: "INTERVAL '0:0:0:50' HOUR_MICROSECOND",
},
{
interval: -50 * time.Microsecond,
expected: "INTERVAL '-0:0:0:50' HOUR_MICROSECOND",
},
{
interval: 50*time.Microsecond + 50*time.Second,
expected: "INTERVAL '0:0:50:50' HOUR_MICROSECOND",
},
{
interval: 50*time.Microsecond +
50*time.Second +
50*time.Minute,
expected: "INTERVAL '0:50:50:50' HOUR_MICROSECOND",
},
{
interval: 50*time.Microsecond +
50*time.Second +
50*time.Minute +
50*time.Hour,
expected: "INTERVAL '50:50:50:50' HOUR_MICROSECOND",
},
{
interval: 50 * time.Hour,
expected: "INTERVAL '50:0:0:0' HOUR_MICROSECOND",
},
{
interval: 50*time.Hour + 50*time.Minute,
expected: "INTERVAL '50:50:0:0' HOUR_MICROSECOND",
},
{
interval: 50*time.Hour + 50*time.Minute + 50*time.Second,
expected: "INTERVAL '50:50:50:0' HOUR_MICROSECOND",
},
{
interval: 0,
expected: "INTERVAL '0:0:0:0' HOUR_MICROSECOND",
},
{
interval: 50 * time.Nanosecond,
expected: "INTERVAL '0:0:0:0' HOUR_MICROSECOND",
},
}
buf := &bytes.Buffer{}
for i, tt := range testTable {
buf.Reset()
err := Interval(tt.interval).Serialize(buf)
c.Assert(err, gc.Equals, tt.expectedErr,
gc.Commentf("experiment #%d", i))
if err == nil {
c.Assert(buf.String(), gc.Equals, tt.expected,
gc.Commentf("experiment #%d", i))
}
}
}