test: expand coverage across readers, writers, cmd, ui, diff and merge
Implements tests/_plans and previously deferred packages; updates plan README with new coverage numbers.
This commit is contained in:
@@ -70,3 +70,54 @@ func TestQuoteDefaultValue(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestQualifiedTableName(t *testing.T) {
|
||||
tests := []struct {
|
||||
schema, table string
|
||||
flatten bool
|
||||
want string
|
||||
}{
|
||||
{"", "t", false, "t"},
|
||||
{"", "t", true, "t"},
|
||||
{"s", "t", false, "s.t"},
|
||||
{"s", "t", true, "s_t"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := QualifiedTableName(tt.schema, tt.table, tt.flatten); got != tt.want {
|
||||
t.Errorf("%+v: got %q", tt, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSanitizeFilename(t *testing.T) {
|
||||
tests := []struct{ in, want string }{
|
||||
{`"users"`, "users"},
|
||||
{`'users'`, "users"},
|
||||
{"`users`", "users"},
|
||||
{"users [note: 'x']", "users"},
|
||||
{"a/b\\c:d*e?f<g>h|i", "a_b_c_d_e_f_g_h_i"},
|
||||
{"__a__b__", "a_b"},
|
||||
{" spaced ", "spaced"},
|
||||
{"ctl\x01char", "ctl_char"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := SanitizeFilename(tt.in); got != tt.want {
|
||||
t.Errorf("%q: got %q want %q", tt.in, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSanitizeStructTagValue(t *testing.T) {
|
||||
tests := []struct{ in, want string }{
|
||||
{"name", "name"},
|
||||
{"`na\"me'`", "name"},
|
||||
{"users [note: 'x']", "users"},
|
||||
{"tags[]", "tags[]"},
|
||||
{" padded ", "padded"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := SanitizeStructTagValue(tt.in); got != tt.want {
|
||||
t.Errorf("%q: got %q want %q", tt.in, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user