From 5c0e0a880035714dc9f39d65d658e8475e816175 Mon Sep 17 00:00:00 2001 From: Pratik Mota Date: Sat, 13 May 2023 00:39:52 +0530 Subject: [PATCH 1/2] test case improvement for Kfcluster --- kfcluster_test.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kfcluster_test.go b/kfcluster_test.go index 4e3075c..0d4d274 100644 --- a/kfcluster_test.go +++ b/kfcluster_test.go @@ -41,18 +41,35 @@ func TestFindKfCluster(t *testing.T) { "pages": 1, "items": [ { - "id": "12345", - "name": "test-kfcluster" - } + "id": "12345", + "name": "test-kfcluster" + }, + { + "id": "12346", + "name": "demo-kfcluster" + } ] }`, }) defer server.Close() + // Exact Match got, _ := client.FindKfCluster("test-kfcluster") if got.ID != "12345" { t.Errorf("Expected %s, got %s", "12345", got.ID) } + + // Multiple Match + _, err := client.FindKfCluster("kfcluster") + if err.Error() != "MultipleMatchesError: unable to find kfcluster 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.FindKfCluster("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 TestCreateKfCluster(t *testing.T) { From 4c25125a59ee82eaa0c14db03a2868d8bd85ad91 Mon Sep 17 00:00:00 2001 From: Pratik Mota Date: Sat, 13 May 2023 00:49:23 +0530 Subject: [PATCH 2/2] error message correction --- kfcluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfcluster_test.go b/kfcluster_test.go index 0d4d274..0c99698 100644 --- a/kfcluster_test.go +++ b/kfcluster_test.go @@ -62,7 +62,7 @@ func TestFindKfCluster(t *testing.T) { // Multiple Match _, err := client.FindKfCluster("kfcluster") if err.Error() != "MultipleMatchesError: unable to find kfcluster because there were multiple matches" { - t.Errorf("Expected %s, got %s", "unable to find volume test there were multiple matches", err.Error()) + t.Errorf("Expected %s, got %s", "unable to find kfcluster as there were multiple matches found", err.Error()) } // Zero Match