From dc724d06c92e1bbba8f5c273247924169302aae9 Mon Sep 17 00:00:00 2001 From: Pratik Mota Date: Fri, 21 Apr 2023 01:09:17 +0530 Subject: [PATCH] Adding test case scenarios for find database --- database_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/database_test.go b/database_test.go index 6864d6a..bcd8293 100644 --- a/database_test.go +++ b/database_test.go @@ -43,16 +43,34 @@ func TestFindDatabase(t *testing.T) { { "id": "12345", "name": "test-db" - } + }, + { + "id": "123456", + "name": "testing-db" + } ] }`, }) defer server.Close() + // Exact Match got, _ := client.FindDatabase("test-db") if got.ID != "12345" { t.Errorf("Expected %s, got %s", "12345", got.ID) } + + // Multiple Match + _, err := client.FindDatabase("test") + if err.Error() != "MultipleMatchesError: unable to find test because there were multiple matches" { + t.Errorf("Expected %s, got %s", "unable to find volume test there were multiple matches", err.Error()) + } + + // Zero Match + _, err = client.FindDatabase("missing") + if err.Error() != "ZeroMatchesError: unable to find missing, zero matches" { + t.Errorf("Expected %s, got %s", "unable to find missing, zero matches", err.Error()) + } + } func TestNewDatabase(t *testing.T) {