Add whitelist feature

This commit is contained in:
Patrick O'brien 2016-09-06 00:41:12 +10:00
parent d5eb79ae28
commit 7144d272bd
9 changed files with 36 additions and 22 deletions

View file

@ -13,7 +13,10 @@ func (m mockDriver) UseLastInsertID() bool { return false }
func (m mockDriver) Open() error { return nil }
func (m mockDriver) Close() {}
func (m mockDriver) TableNames(exclude []string) ([]string, error) {
func (m mockDriver) TableNames(whitelist, exclude []string) ([]string, error) {
if len(whitelist) > 0 {
return whitelist, nil
}
tables := []string{"pilots", "jets", "airports", "licenses", "hangars", "languages", "pilot_languages"}
return strmangle.SetComplement(tables, exclude), nil
}
@ -96,7 +99,7 @@ func (m mockDriver) PrimaryKeyInfo(tableName string) (*PrimaryKey, error) {
func TestTables(t *testing.T) {
t.Parallel()
tables, err := Tables(mockDriver{})
tables, err := Tables(mockDriver{}, nil, nil)
if err != nil {
t.Error(err)
}