From 7a04587194aece4bf1e219a8abf3401ad014dd86 Mon Sep 17 00:00:00 2001 From: rishi-salunkhe-mettle Date: Mon, 25 Nov 2024 13:36:29 -0600 Subject: [PATCH] Reverted the logs in BundleQuerierParser to fatal level (previous change was not necessary and added Go lintr errors). Rectified the conditional statements in the webscraper test files. --- .../pkg/chplendpointquerier/bundleQuerierParser.go | 10 +++------- .../pkg/chplendpointquerier/commomwebscrapers_test.go | 2 +- .../chplendpointquerier/guidewellurlwebscraper_test.go | 8 ++++---- .../pkg/chplendpointquerier/hcscwebscraper_test.go | 8 ++++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/endpointmanager/pkg/chplendpointquerier/bundleQuerierParser.go b/endpointmanager/pkg/chplendpointquerier/bundleQuerierParser.go index de84f18c9..791bed1c4 100644 --- a/endpointmanager/pkg/chplendpointquerier/bundleQuerierParser.go +++ b/endpointmanager/pkg/chplendpointquerier/bundleQuerierParser.go @@ -5,14 +5,13 @@ import ( log "github.com/sirupsen/logrus" ) -func BundleQuerierParser(CHPLURL string, fileToWriteTo string) error { +func BundleQuerierParser(CHPLURL string, fileToWriteTo string) { var endpointEntryList EndpointList respBody, err := helpers.QueryEndpointList(CHPLURL) if err != nil { - log.Info(err) - return err + log.Fatal(err) } // convert bundle data to lantern format @@ -20,9 +19,6 @@ func BundleQuerierParser(CHPLURL string, fileToWriteTo string) error { err = WriteCHPLFile(endpointEntryList, fileToWriteTo) if err != nil { - log.Info(err) - return err + log.Fatal(err) } - - return nil } diff --git a/endpointmanager/pkg/chplendpointquerier/commomwebscrapers_test.go b/endpointmanager/pkg/chplendpointquerier/commomwebscrapers_test.go index 51439dd54..515b4c741 100644 --- a/endpointmanager/pkg/chplendpointquerier/commomwebscrapers_test.go +++ b/endpointmanager/pkg/chplendpointquerier/commomwebscrapers_test.go @@ -51,7 +51,7 @@ func TestWebScrapers(t *testing.T) { func runWebScraperTest(t *testing.T, scraperFunc WebScraperFunc, url, fileName string) { err := scraperFunc(url, fileName) - if err != nil { + if err == nil { fileExists, err := doesfileExist(fileName) th.Assert(t, err == nil, err) th.Assert(t, fileExists, "File does not exist") diff --git a/endpointmanager/pkg/chplendpointquerier/guidewellurlwebscraper_test.go b/endpointmanager/pkg/chplendpointquerier/guidewellurlwebscraper_test.go index aefbb3666..5beaa0034 100644 --- a/endpointmanager/pkg/chplendpointquerier/guidewellurlwebscraper_test.go +++ b/endpointmanager/pkg/chplendpointquerier/guidewellurlwebscraper_test.go @@ -13,7 +13,7 @@ func Test_GuidewellURLWebscraper(t *testing.T) { // 1. Happy case: Valid url, valid file format err := GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/306/api/285#/CMSInteroperabilityPatientAccessMetadata_100/operation/%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPatientAccessEndpointSources.json") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_GuidewellPatientAccessEndpointSources.json") th.Assert(t, err == nil, err) th.Assert(t, fileExists, "JSON file does not exist") @@ -32,7 +32,7 @@ func Test_GuidewellURLWebscraper(t *testing.T) { // 2. Different file format err = GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/306/api/285#/CMSInteroperabilityPatientAccessMetadata_100/operation/%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPatientAccessEndpointSources.csv") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_GuidewellPatientAccessEndpointSources.csv") th.Assert(t, err == nil, err) th.Assert(t, fileExists, "CSV file does not exist") @@ -52,7 +52,7 @@ func Test_GuidewellURLWebscraper(t *testing.T) { // 1. Happy case: Valid url, valid file format err = GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/309/api/288#/CMSInteroperabilityPayer2PayerOutboundMetadata_100/operation/%2FP2P%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPayer2PayerEndpointSources.json") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_GuidewellPayer2PayerEndpointSources.json") th.Assert(t, err == nil, err) th.Assert(t, fileExists, "JSON file does not exist") @@ -71,7 +71,7 @@ func Test_GuidewellURLWebscraper(t *testing.T) { // 2. Different file format err = GuidewellURLWebscraper("https://developer.bcbsfl.com/interop/interop-developer-portal/product/309/api/288#/CMSInteroperabilityPayer2PayerOutboundMetadata_100/operation/%2FP2P%2FR4%2Fmetadata/get", "TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_GuidewellPayer2PayerEndpointSources.csv") th.Assert(t, err == nil, err) th.Assert(t, fileExists, "CSV file does not exist") diff --git a/endpointmanager/pkg/chplendpointquerier/hcscwebscraper_test.go b/endpointmanager/pkg/chplendpointquerier/hcscwebscraper_test.go index 54d55eb09..560fb496e 100644 --- a/endpointmanager/pkg/chplendpointquerier/hcscwebscraper_test.go +++ b/endpointmanager/pkg/chplendpointquerier/hcscwebscraper_test.go @@ -31,7 +31,7 @@ func Test_HcscURLWebscraper(t *testing.T) { // 1. Happy case: Valid url, valid file format err := HcscURLWebscraper("https://interoperability.hcsc.com/s/provider-directory-api", "TEST_Medicare_HCSCEndpointSources.json") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_HCSCEndpointSources.json") th.Assert(t, err == nil, err) th.Assert(t, fileExists, "JSON file does not exist") @@ -50,7 +50,7 @@ func Test_HcscURLWebscraper(t *testing.T) { // 2. Empty inputs err = HcscURLWebscraper("", "") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_HCSCEndpointSources.json") th.Assert(t, err == nil, err) th.Assert(t, !fileExists, "File exists for invalid inputs") @@ -63,7 +63,7 @@ func Test_HcscURLWebscraper(t *testing.T) { // 3. Different file format err = HcscURLWebscraper("https://interoperability.hcsc.com/s/provider-directory-api", "TEST_Medicare_HCSCEndpointSources.csv") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_HCSCEndpointSources.csv") th.Assert(t, err == nil, err) th.Assert(t, fileExists, "CSV file does not exist") @@ -76,7 +76,7 @@ func Test_HcscURLWebscraper(t *testing.T) { // 4. Invalid URL err = HcscURLWebscraper("https://non-existent-url.com/dummy-api", "TEST_Medicare_HCSCEndpointSources.json") - if err != nil { + if err == nil { fileExists, err := doesfileExist("TEST_Medicare_HCSCEndpointSources.json") th.Assert(t, err == nil, err) th.Assert(t, !fileExists, "File exists for invalid URL")