diff --git a/bcda/client/bluebutton_test.go b/bcda/client/bluebutton_test.go index aa8ef7195..4ca69b4bd 100644 --- a/bcda/client/bluebutton_test.go +++ b/bcda/client/bluebutton_test.go @@ -8,6 +8,7 @@ import ( "net/http/httptest" "net/url" "os" + "strconv" "strings" "testing" "time" @@ -16,6 +17,7 @@ import ( "github.com/CMSgov/bcda-app/bcda/constants" "github.com/CMSgov/bcda-app/bcda/models" fhirModels "github.com/CMSgov/bcda-app/bcda/models/fhir" + "github.com/CMSgov/bcda-app/bcda/testUtils" "github.com/CMSgov/bcda-app/conf" "github.com/sirupsen/logrus" "github.com/sirupsen/logrus/hooks/test" @@ -44,6 +46,7 @@ type BBRequestTestSuite struct { var ( ts200, ts500 *httptest.Server + logger = testUtils.GetLogger(logrus.StandardLogger()) now = time.Now() nowFormatted = url.QueryEscape(now.Format(time.RFC3339Nano)) since = "gt2020-02-14" @@ -60,7 +63,7 @@ func (s *BBTestSuite) SetupSuite() { conf.SetEnv(s.T(), "BB_TIMEOUT_MS", "2000") // Set up the logger since we're using the real client - client.SetLogger(logrus.StandardLogger()) + client.SetLogger(logger) } func (s *BBRequestTestSuite) SetupSuite() { @@ -74,6 +77,7 @@ func (s *BBRequestTestSuite) SetupSuite() { } func (s *BBRequestTestSuite) BeforeTest(suiteName, testName string) { + client.SetLogger(logger) if strings.Contains(testName, "500") { s.ts = ts500 } else { @@ -223,6 +227,25 @@ func (s *BBTestSuite) TestGetDefaultParams() { } +func (s *BBRequestTestSuite) TestGetBBLogs() { + hook := test.NewLocal(logger) + _, err := s.bbClient.GetPatient(jobData, "012345") + var logCMSID, logJobID bool + for _, entry := range hook.AllEntries() { + test := entry.Data + s.T().Log(test) + if entry.Data["cms_id"] == jobData.CMSID { + logCMSID = true + } + if entry.Data["job_id"] == strconv.Itoa(jobData.ID) { + logJobID = true + } + } + assert.True(s.T(), logCMSID) + assert.True(s.T(), logJobID) + assert.Nil(s.T(), err) +} + /* Tests that make requests, using clients configured with the 200 response and 500 response httptest.Servers initialized in SetupSuite() */ func (s *BBRequestTestSuite) TestGetPatient() { p, err := s.bbClient.GetPatient(jobData, "012345") diff --git a/bcda/service/service.go b/bcda/service/service.go index 85a94223d..857f9d7e6 100644 --- a/bcda/service/service.go +++ b/bcda/service/service.go @@ -295,6 +295,7 @@ func (s *service) createQueueJobs(conditions RequestConditions, since time.Time, enqueueArgs := models.JobEnqueueArgs{ ID: int(conditions.JobID), ACOID: conditions.ACOID.String(), + CMSID: conditions.CMSID, BeneficiaryIDs: jobIDs, ResourceType: rt, Since: sinceArg, @@ -307,6 +308,7 @@ func (s *service) createQueueJobs(conditions RequestConditions, since time.Time, jobs = append(jobs, &enqueueArgs) } + } else { // This should never be possible, would have returned earlier return nil, errors.New("Invalid resource type: " + rt)