From 82d1898b12b2e32e4b0cb359a487f7feffc7d57b Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 13 Oct 2013 20:03:11 -0500 Subject: [PATCH] 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. --- interface_test.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/interface_test.go b/interface_test.go index b28bd64e..66ea7926 100644 --- a/interface_test.go +++ b/interface_test.go @@ -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 + } }