From f602a8061298f3a8e29e6bc845d102f4c19252eb Mon Sep 17 00:00:00 2001 From: "anjali.agarwal" Date: Thu, 5 Oct 2023 08:47:12 +0530 Subject: [PATCH] add test cases --- .../discovery_search_repository_test.go | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/internal/store/elasticsearch/discovery_search_repository_test.go b/internal/store/elasticsearch/discovery_search_repository_test.go index cf387845..89f412a6 100644 --- a/internal/store/elasticsearch/discovery_search_repository_test.go +++ b/internal/store/elasticsearch/discovery_search_repository_test.go @@ -95,6 +95,39 @@ func TestSearcherSearch(t *testing.T) { {Type: "topic", AssetID: "transaction", Service: "rabbitmq", Data: map[string]interface{}{"company": "gotocompany", "description": "This publishes all the invoices from each of invoice storage where the invoice will be filtered and checked using invoice filterer and invoice checker", "environment": "production", "partition": float64(1), "topic_name": "transaction"}}, }, }, + { + Description: "should fetch assets with empty text", + Config: asset.SearchConfig{ + Text: "", + IncludeFields: []string{"id", "type"}, + Filters: map[string][]string{"service": {"bigquery"}}, + }, + Expected: []expectedRow{ + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-1"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-common"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-abc-common-test"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-mid"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/abc-tablename-mid"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/test"}, + }, + }, + { + Description: "should fetch assets with empty text and rank by", + Config: asset.SearchConfig{ + Text: "", + RankBy: "data.profile.usage_count", + IncludeFields: []string{"id", "type"}, + Filters: map[string][]string{"service": {"bigquery"}}, + }, + Expected: []expectedRow{ + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-common"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-mid"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/test"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-1"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/tablename-abc-common-test"}, + {Type: "table", AssetID: "bigquery::gcpproject/dataset/abc-tablename-mid"}, + }, + }, { Description: "should fetch assets which has text in any of its fields", Config: asset.SearchConfig{