Skip to content

Commit

Permalink
Reverted the logs in BundleQuerierParser to fatal level (previous cha…
Browse files Browse the repository at this point in the history
…nge was not necessary and added Go lintr errors). Rectified the conditional statements in the webscraper test files.
  • Loading branch information
rishi-salunkhe-mettle committed Nov 25, 2024
1 parent 7a900b4 commit 7a04587
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
10 changes: 3 additions & 7 deletions endpointmanager/pkg/chplendpointquerier/bundleQuerierParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@ 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
endpointEntryList.Endpoints = BundleToLanternFormat(respBody)

err = WriteCHPLFile(endpointEntryList, fileToWriteTo)
if err != nil {
log.Info(err)
return err
log.Fatal(err)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 7a04587

Please sign in to comment.