2016-07-12 05:40:24 +02:00
|
|
|
package bdb
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2016-07-12 08:48:30 +02:00
|
|
|
func TestGetTable(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
tables := []Table{
|
|
|
|
{Name: "one"},
|
|
|
|
}
|
|
|
|
|
|
|
|
tbl := GetTable(tables, "one")
|
|
|
|
|
|
|
|
if tbl.Name != "one" {
|
|
|
|
t.Error("didn't get column")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetTableMissing(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
tables := []Table{
|
|
|
|
{Name: "one"},
|
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r == nil {
|
|
|
|
t.Error("expected a panic failure")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
GetTable(tables, "missing")
|
|
|
|
}
|
|
|
|
|
2016-07-12 05:40:24 +02:00
|
|
|
func TestGetColumn(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
table := Table{
|
|
|
|
Columns: []Column{
|
2016-08-08 09:46:06 +02:00
|
|
|
{Name: "one"},
|
2016-07-12 05:40:24 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
c := table.GetColumn("one")
|
|
|
|
|
|
|
|
if c.Name != "one" {
|
|
|
|
t.Error("didn't get column")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetColumnMissing(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
table := Table{
|
|
|
|
Columns: []Column{
|
2016-08-08 09:47:33 +02:00
|
|
|
{Name: "one"},
|
2016-07-12 05:40:24 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r == nil {
|
|
|
|
t.Error("expected a panic failure")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
table.GetColumn("missing")
|
|
|
|
}
|