test(qb): Add tests for qb section (#74)

test(qb): Add missing tests for qb directory

* Add a GROUP BY test without Columns
* Add LtFunc test
* Add LtOrEqFunc test
* Add GtFunc test
* Add GtOrEqFunc test
* Add a Select with a AS between one column test
* Add a Order By DESC test
* Add Sum test
* Add Avg test
* Add Max test
* Add 2 tests for FuncColumn
* Add SetNamed test
* Add AddFunc test
* Add RemoveFunc test
* Add TTL and TimestampNamed test
* Add TTLNamed and Timestamp test
* Add TTL with negative or no duration test
* Add LtFunc test
* Add LtOrEqFunc test
* Add GtFunc test
* Add GtOrEqFunc test
* Add a Select with a AS between one column test
* Add a Order By DESC test
* Add Sum test
* Add Avg test
* Add Max test
* Add SetNamed test
* Add AddFunc test
* Add RemoveFunc test
* Add TTL and TimestampNamed test
* Add TTLNamed and Timestamp test
* Add TTL with negative or no duration test
* Add LtFunc test
* Add LtOrEqFunc test
* Add GtFunc test
* Add GtOrEqFunc test
* Add a Select with a AS between one column test
* Add a Order By DESC test
* Add Sum test
* Add Avg test
* Add Max test
* Add 2 tests for FuncColumn
* Add SetNamed test
* Add AddFunc test
* Add RemoveFunc test
* In qb/select.go, if there are no colums and the query have a GroupBy
statement then the query will be malformated.
* In qb/utils.go, refactor writeCql with a strings.Join call.

Fixes #78
This commit is contained in:
Marian Gappa
2018-12-17 15:40:03 +01:00
committed by Michal Matczuk
parent dcec9d031f
commit 87976451ed
5 changed files with 100 additions and 0 deletions

View File

@@ -57,12 +57,38 @@ func TestUsing(t *testing.T) {
B: new(using).TTL(time.Second).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
S: "USING TTL 1 AND TIMESTAMP 1115251200000000 ",
},
// TTL TimestampNamed
{
B: new(using).TTL(time.Second).TimestampNamed("ts"),
S: "USING TTL 1 AND TIMESTAMP ? ",
N: []string{"ts"},
},
// TTLNamed TimestampNamed
{
B: new(using).TTLNamed("ttl").TimestampNamed("ts"),
S: "USING TTL ? AND TIMESTAMP ? ",
N: []string{"ttl", "ts"},
},
// TTLNamed Timestamp
{
B: new(using).TTLNamed("ttl").Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
S: "USING TTL ? AND TIMESTAMP 1115251200000000 ",
N: []string{"ttl"},
},
// TTL with no duration
{
B: new(using).TTL(0 * time.Second),
S: "USING TTL 0 ",
},
{
B: new(using).TTL(-1 * time.Second),
S: "USING TTL 0 ",
},
{
// TODO patch this maybe in the future
B: new(using).TTL(-2 * time.Second),
S: "USING TTL -2 ",
},
// TTL TTLNamed
{
B: new(using).TTL(time.Second).TTLNamed("ttl"),