05f155ecc0
Signed-off-by: Anton Nesterov <anton@demiurg.io>
45 lines
775 B
Go
45 lines
775 B
Go
package builder
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestConvertFieldsBool(t *testing.T) {
|
|
result, err := convertFields([]Map{
|
|
{"test": true},
|
|
{"test2": false},
|
|
})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if result != `test` {
|
|
t.Errorf("Expected test, got %s", result)
|
|
}
|
|
}
|
|
|
|
func TestConvertFieldsInt(t *testing.T) {
|
|
result, err := convertFields([]Map{
|
|
{"test": 0},
|
|
{"test2": 1},
|
|
})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if result != `test2` {
|
|
t.Errorf("Expected test, got %s", result)
|
|
}
|
|
}
|
|
|
|
func TestConvertFieldsStr(t *testing.T) {
|
|
result, err := convertFields([]Map{
|
|
{"t.test": "Test"},
|
|
{"SUM(t.test, t.int)": "Sum"},
|
|
})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if result != `t.test AS Test, SUM(t.test, t.int) AS Sum` {
|
|
t.Errorf("Expected test, got %s", result)
|
|
}
|
|
}
|