Add interface test for unsupported dbtype failures.

This commit adds an interface test to ensure that the interface returns
the expected error when trying to open or create an unsupported database
type.
This commit is contained in:
Dave Collins 2013-10-13 20:03:11 -05:00
parent d4c1214496
commit 82d1898b12

View file

@ -133,5 +133,27 @@ func TestCreateOpenFail(t *testing.T) {
"got: %v, want %v", err, openError)
return
}
}
// TestCreateOpenUnsupported ensures that attempting to create or open an
// unsupported database type is handled properly.
func TestCreateOpenUnsupported(t *testing.T) {
// Ensure creating a database with an unsupported type fails with the
// expected error.
dbType := "unsupported"
_, err := btcdb.CreateDB(dbType, "unsupportedcreatetest")
if err != btcdb.DbUnknownType {
t.Errorf("TestCreateOpenUnsupported: expected error not "+
"received - got: %v, want %v", err, btcdb.DbUnknownType)
return
}
// Ensure opening a database with the new type fails with the expected
// error.
_, err = btcdb.OpenDB(dbType, "unsupportedopentest")
if err != btcdb.DbUnknownType {
t.Errorf("TestCreateOpenUnsupported: expected error not "+
"received - got: %v, want %v", err, btcdb.DbUnknownType)
return
}
}