mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 17:28:54 +00:00
6a825c11e3
Removed Gorm, replaced it with Sqlx * Added SQL bundling command to Makfile * Using go-kit logger * Added soft delete capability * Changed SearchLabel to accept a variadic param for optional omit list instead of array * Gorm removed * Refactor table structures to use CURRENT_TIMESTAMP mysql function * Moved Inmem datastore into it's own package * Updated README * Implemented code review suggestions from @zwass * Removed reference to Gorm from glide.yaml
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package mysql
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kolide/kolide-ose/server/kolide"
|
|
)
|
|
|
|
func TestAppendListOptionsToSQL(t *testing.T) {
|
|
sql := "SELECT * FROM app_configs"
|
|
opts := kolide.ListOptions{
|
|
OrderKey: "name",
|
|
}
|
|
|
|
actual := appendListOptionsToSQL(sql, opts)
|
|
expected := "SELECT * FROM app_configs ORDER BY name ASC LIMIT 1000"
|
|
if actual != expected {
|
|
t.Error("Expected", expected, "Actual", actual)
|
|
}
|
|
|
|
sql = "SELECT * FROM app_configs"
|
|
opts.OrderDirection = kolide.OrderDescending
|
|
actual = appendListOptionsToSQL(sql, opts)
|
|
expected = "SELECT * FROM app_configs ORDER BY name DESC LIMIT 1000"
|
|
if actual != expected {
|
|
t.Error("Expected", expected, "Actual", actual)
|
|
}
|
|
|
|
opts = kolide.ListOptions{
|
|
PerPage: 10,
|
|
}
|
|
|
|
sql = "SELECT * FROM app_configs"
|
|
actual = appendListOptionsToSQL(sql, opts)
|
|
expected = "SELECT * FROM app_configs LIMIT 10"
|
|
if actual != expected {
|
|
t.Error("Expected", expected, "Actual", actual)
|
|
}
|
|
|
|
sql = "SELECT * FROM app_configs"
|
|
opts.Page = 2
|
|
actual = appendListOptionsToSQL(sql, opts)
|
|
expected = "SELECT * FROM app_configs LIMIT 10 OFFSET 20"
|
|
if actual != expected {
|
|
t.Error("Expected", expected, "Actual", actual)
|
|
}
|
|
|
|
opts = kolide.ListOptions{}
|
|
sql = "SELECT * FROM app_configs"
|
|
actual = appendListOptionsToSQL(sql, opts)
|
|
expected = "SELECT * FROM app_configs LIMIT 1000"
|
|
|
|
if actual != expected {
|
|
t.Error("Expected", expected, "Actual", actual)
|
|
}
|
|
|
|
}
|