Skip to content

Commit

Permalink
Merge pull request #65 from sizets/generatre-vcr-recordings
Browse files Browse the repository at this point in the history
generated Vcr recordings for disabled tests and added new tests
  • Loading branch information
AnalogJ authored Nov 23, 2024
2 parents d326839 + b7a81c5 commit 454fd9e
Show file tree
Hide file tree
Showing 32 changed files with 383,580 additions and 41,659 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ js/node_modules
js/local.log
js/playwright-report
js/test-results
vendor
74 changes: 43 additions & 31 deletions clients/internal/allscripts_test.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
package internal

//
//func TestGetSourceClientAllscripts_SyncAll(t *testing.T) {
//TODO: need to regenerate with _count
//t.Skipf("skipping test, need to regenerate with _count")
// t.Parallel()
// //setup
// testLogger := logrus.WithFields(logrus.Fields{
// "type": "test",
// })
// mockCtrl := gomock.NewController(t)
// defer mockCtrl.Finish()
// fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
// fakeDatabase.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).Times(158).Return(true, nil)
//
// fakeSourceCredential := mock_models.NewMockSourceCredential(mockCtrl)
// fakeSourceCredential.EXPECT().GetPatientId().AnyTimes().Return("6709dc13-ca3e-4969-886a-fe0889eb8256")
// fakeSourceCredential.EXPECT().GetSourceType().AnyTimes().Return(pkg.SourceTypeAllscripts)
// fakeSourceCredential.EXPECT().GetApiEndpointBaseUrl().AnyTimes().Return("https://pro171fmh.open.allscripts.com/open")
//
// httpClient := base.OAuthVcrSetup(t, false)
// client, _, err := GetSourceClientAllscripts(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, fakeSourceCredential, httpClient)
//
// //test
// resp, err := client.SyncAll(fakeDatabase)
// require.NoError(t, err)
//
// //assert
// require.NoError(t, err)
// require.Equal(t, 158, resp.TotalResources)
// require.Equal(t, 158, len(resp.UpdatedResources))
//}
import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

func TestGetSourceClientAllscripts_SyncAll(t *testing.T) {
// TODO: need to regenerate with _count
t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
fakeDatabase.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).Times(158).Return(true, nil)

fakeSourceCredential := mock_models.NewMockSourceCredential(mockCtrl)
fakeSourceCredential.EXPECT().GetPatientId().AnyTimes().Return("6709dc13-ca3e-4969-886a-fe0889eb8256")
fakeSourceCredential.EXPECT().GetPlatformType().AnyTimes().Return(pkg.PlatformTypeAllscripts)
fakeSourceCredential.EXPECT().GetEndpointId().AnyTimes().Return("7682675b-8247-4fda-b2cd-048bfeafc8af")

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

//test
resp, err := client.SyncAll(fakeDatabase)
require.NoError(t, err)

//assert
require.NoError(t, err)
require.Equal(t, 158, resp.TotalResources)
require.Equal(t, 158, len(resp.UpdatedResources))
}
5 changes: 3 additions & 2 deletions clients/internal/athena_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package internal

import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"testing"
)

func TestGetSourceClientAthena_SyncAll(t *testing.T) {
//TODO: need to regenerate with _count
t.Skipf("skipping test, need to regenerate with _count")
// t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
Expand Down
5 changes: 3 additions & 2 deletions clients/internal/careevolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package internal

import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"testing"
)

func TestGetSourceClientCareevolution_SyncAll(t *testing.T) {
//TODO: need to regenerate with _count
t.Skipf("skipping test, need to regenerate with _count")
// t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
Expand Down
91 changes: 44 additions & 47 deletions clients/internal/cerner_test.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
package internal

//
//import (
// "context"
// "github.com/fastenhealth/fasten-sources/clients/internal/base"
// "github.com/fastenhealth/fasten-sources/clients/models"
// mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
// "github.com/fastenhealth/fasten-sources/pkg"
// "github.com/golang/mock/gomock"
// "github.com/sirupsen/logrus"
// "github.com/stretchr/testify/require"
// "testing"
//)
//
//func TestGetSourceClientCerner_SyncAll(t *testing.T) {
//TODO: need to regenerate with _count
//t.Skipf("skipping test, need to regenerate with _count")
// t.Parallel()
// //setup
// testLogger := logrus.WithFields(logrus.Fields{
// "type": "test",
// })
// mockCtrl := gomock.NewController(t)
// defer mockCtrl.Finish()
// fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
// 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("12724067")
// fakeSourceCredential.EXPECT().GetPlatformType().AnyTimes().Return(pkg.PlatformTypeCerner)
// fakeSourceCredential.EXPECT().GetEndpointId().AnyTimes().Return("3290e5d7-978e-42ad-b661-1cf8a01a989c")
//
// httpClient := base.OAuthVcrSetup(
// t,
// false,
// )
// client, err := GetDynamicSourceClient(pkg.FastenLighthouseEnvSandbox, context.Background(), testLogger, fakeSourceCredential, models.WithTestHttpClient(httpClient))
//
// //test
// resp, err := client.SyncAll(fakeDatabase)
// require.NoError(t, err)
//
// //assert
// require.NoError(t, err)
// require.Equal(t, 864, resp.TotalResources)
// require.Equal(t, 853, len(resp.UpdatedResources))
//}
import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

func TestGetSourceClientCerner_SyncAll(t *testing.T) {
// TODO: need to regenerate with _count
// t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
fakeDatabase.EXPECT().UpsertRawResource(gomock.Any(), gomock.Any(), gomock.Any()).Times(180).Return(true, nil)
fakeDatabase.EXPECT().BackgroundJobCheckpoint(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return()

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

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

//test
resp, err := client.SyncAll(fakeDatabase)
require.NoError(t, err)

//assert

require.Equal(t, 864, resp.TotalResources)
require.Equal(t, 853, len(resp.UpdatedResources))
}
46 changes: 46 additions & 0 deletions clients/internal/chbase_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package internal

import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

func TestGetSourceClientChBase_SyncAll(t *testing.T) {
// TODO: need to regenerate with _count
// t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
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("47c1df49-98a3-470e-bc51-69c8773f4cbf")
fakeSourceCredential.EXPECT().GetPlatformType().AnyTimes().Return(pkg.PlatformTypeCHBase)
fakeSourceCredential.EXPECT().GetEndpointId().AnyTimes().Return("ee5e19b6-4539-4e46-baab-b892061fe448")

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

//test
resp, err := client.SyncAll(fakeDatabase)
require.NoError(t, err)

//assert
require.NoError(t, err)
require.Equal(t, 65, resp.TotalResources)
require.Equal(t, 66, len(resp.UpdatedResources))
}
46 changes: 46 additions & 0 deletions clients/internal/cigna_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package internal

import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

func TestGetSourceClientCigna_SyncAll(t *testing.T) {
// TODO: need to regenerate with _count
// t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
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("A00000000000005")
fakeSourceCredential.EXPECT().GetPlatformType().AnyTimes().Return(pkg.PlatformTypeCigna)
fakeSourceCredential.EXPECT().GetEndpointId().AnyTimes().Return("6c0454af-1631-4c4d-905d-5710439df983")

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

//test
resp, err := client.SyncAll(fakeDatabase)
require.NoError(t, err)

//assert
require.NoError(t, err)
require.Equal(t, 29, resp.TotalResources)
require.Equal(t, 21, len(resp.UpdatedResources))
}
46 changes: 46 additions & 0 deletions clients/internal/drChrono_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package internal

import (
"context"
"testing"

"github.com/fastenhealth/fasten-sources/clients/internal/base"
"github.com/fastenhealth/fasten-sources/clients/models"
mock_models "github.com/fastenhealth/fasten-sources/clients/models/mock"
"github.com/fastenhealth/fasten-sources/pkg"
"github.com/golang/mock/gomock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

func TestGetSourceClientDrChrono_SyncAll(t *testing.T) {
//TODO: need to regenerate with _count
// t.Skipf("skipping test, need to regenerate with _count")
t.Parallel()
//setup
testLogger := logrus.WithFields(logrus.Fields{
"type": "test",
})
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeDatabase := mock_models.NewMockDatabaseRepository(mockCtrl)
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("7670a27f-cb14-475a-ac72-c06a0a8dfea0")
fakeSourceCredential.EXPECT().GetPlatformType().AnyTimes().Return(pkg.PlatformTypeDrChrono)
fakeSourceCredential.EXPECT().GetEndpointId().AnyTimes().Return("6a01ffff-d73e-4728-a315-9b23bd77a4cc")

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

//test
resp, err := client.SyncAll(fakeDatabase)
require.NoError(t, err)

//assert
require.NoError(t, err)
require.Equal(t, 85, resp.TotalResources)
require.Equal(t, 73, len(resp.UpdatedResources))
}
Loading

0 comments on commit 454fd9e

Please sign in to comment.