Skip to content

Commit

Permalink
make sure the manual client is compliant.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed May 7, 2024
1 parent a786e70 commit 23b7617
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 55,163 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.PHONY: dep-backend
dep-backend:
go mod vendor
.PHONY: deps
deps:
go mod tidy && go mod vendor

.PHONY: serve-backend
serve-backend: dep-backend
serve-backend: deps
cd testutils && go run oauth_cli.go


test:
go test ./...
4 changes: 1 addition & 3 deletions catalog/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ func TestCatalog_GetBrands_WithSandboxMode(t *testing.T) {

//assert
require.NoError(t, err)
require.Len(t, brands, 20)
require.Len(t, brands, 27)

for _, brand := range brands {
if brand.Id == "db814755-2b62-4549-ba65-5138c0b80536" {
require.Len(t, brand.PortalsIds, 2)
} else {
require.Len(t, brand.PortalsIds, 1)
}
}
}
Expand Down
37 changes: 32 additions & 5 deletions clients/internal/base/fhir401_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"encoding/json"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/definitions"
definitionsModels "github.com/fastenhealth/fasten-sources/definitions/models"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/fastenhealth/gofhir-models/fhir401"
"github.com/golang/mock/gomock"
Expand All @@ -27,8 +29,10 @@ func TestNewFHIR401Client(t *testing.T) {
"type": "test",
})

endpointDefinition := &definitionsModels.LighthouseSourceDefinition{}

//test
client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, &http.Client{})
client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, endpointDefinition, &http.Client{})

//assert
require.NoError(t, err)
Expand All @@ -47,7 +51,13 @@ func TestFHIR401Client_ProcessBundle_Cigna(t *testing.T) {
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, &http.Client{})

cignaSandboxDefinition, err := definitions.GetSourceDefinition(definitions.GetSourceConfigOptions{
EndpointId: "6c0454af-1631-4c4d-905d-5710439df983",
})
require.NoError(t, err)

client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, cignaSandboxDefinition, &http.Client{})
require.NoError(t, err)

jsonBytes, err := ReadTestFixture("testdata/fixtures/401-R4/bundle/cigna_syntheticuser05-everything.json")
Expand Down Expand Up @@ -77,7 +87,13 @@ func TestFHIR401Client_ProcessBundle_Cerner(t *testing.T) {
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, &http.Client{})

cernerSandboxDefinition, err := definitions.GetSourceDefinition(definitions.GetSourceConfigOptions{
EndpointId: "3290e5d7-978e-42ad-b661-1cf8a01a989c",
})
require.NoError(t, err)

client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, cernerSandboxDefinition, &http.Client{})
require.NoError(t, err)

jsonBytes, err := ReadTestFixture("testdata/fixtures/401-R4/bundle/cerner_open_12724067_DocumentReference.json")
Expand Down Expand Up @@ -106,7 +122,13 @@ func TestFhir401Client_ProcessResource(t *testing.T) {
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, &http.Client{})

cernerSandboxDefinition, err := definitions.GetSourceDefinition(definitions.GetSourceConfigOptions{
EndpointId: "3290e5d7-978e-42ad-b661-1cf8a01a989c",
})
require.NoError(t, err)

client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, cernerSandboxDefinition, &http.Client{})
require.NoError(t, err)
db.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil).AnyTimes()

Expand Down Expand Up @@ -151,7 +173,12 @@ func TestFhir401Client_ProcessResourceWithContainedResources(t *testing.T) {
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, &http.Client{})
medicareSandboxDefinition, err := definitions.GetSourceDefinition(definitions.GetSourceConfigOptions{
EndpointId: "6ae6c14e-b927-4ce0-862f-91123cb8d774",
})
require.NoError(t, err)

client, err := GetSourceClientFHIR401(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, sc, medicareSandboxDefinition, &http.Client{})
require.NoError(t, err)
db.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil).AnyTimes()

Expand Down
9 changes: 6 additions & 3 deletions clients/internal/cerner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ func TestGetSourceClientCerner_SyncAll(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
fakeDatabase.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).Times(853).Return(true, nil)
fakeDatabase.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return(true, nil)
fakeDatabase.EXPECT().BackgroundJobCheckpoint(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return()

fakeSourceCredential := mock_models.NewMockSourceCredential(mockCtrl)
fakeSourceCredential.EXPECT().GetPatientId().AnyTimes().Return("12742397")
fakeSourceCredential.EXPECT().GetPatientId().AnyTimes().Return("12724067")
fakeSourceCredential.EXPECT().GetPlatformType().AnyTimes().Return(pkg.PlatformTypeCerner)
fakeSourceCredential.EXPECT().GetEndpointId().AnyTimes().Return("3290e5d7-978e-42ad-b661-1cf8a01a989c")

httpClient := base.OAuthVcrSetup(t, false)
httpClient := base.OAuthVcrSetup(
t,
false,
)
client, err := GetDynamicSourceClient(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, fakeSourceCredential, httpClient)

//test
Expand Down
55,148 changes: 0 additions & 55,148 deletions clients/internal/testdata/govcr-fixtures/TestGetSourceClientCerner_SyncAll.cassette

This file was deleted.

0 comments on commit 23b7617

Please sign in to comment.