Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close output writers in post processors #369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/data_source/post_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
return nil, status.Error(codes.Internal, err.Error())
}

defer outputWriter.Close()

Check warning on line 62 in internal/data_source/post_processor.go

View check run for this annotation

Codecov / codecov/patch

internal/data_source/post_processor.go#L62

Added line #L62 was not covered by tests

p.config.TargetLogger.Debug(fmt.Sprintf("Post processor streaming data objects from file %s", inputFilePath))

inputFile, err := os.Open(inputFilePath)
Expand Down
2 changes: 2 additions & 0 deletions internal/identity_store/post_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func (p *PostProcessor) PostProcessUsers(usersInputFilePath string, usersOutputF
return nil, p.errorWrapper(err)
}

defer outputWriter.Close()

p.config.TargetLogger.Debug(fmt.Sprintf("Post processor streaming users from file %s", usersInputFilePath))

usersInputFile, err := os.Open(usersInputFilePath)
Expand Down
20 changes: 12 additions & 8 deletions internal/identity_store/post_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func TestPostProcessor_PostProcess(t *testing.T) {
{
name: "no config",
fields: fields{
setup: func(accessProviderFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
accessProviderFileCreator.EXPECT().GetUserCount().Return(1).Once()
setup: func(identityFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
identityFileCreator.EXPECT().GetUserCount().Return(1).Once()
identityFileCreator.EXPECT().Close().Return().Once()

identityStoreFileCreatorError = nil

Expand Down Expand Up @@ -81,8 +82,9 @@ func TestPostProcessor_PostProcess(t *testing.T) {
{
name: "wrong config",
fields: fields{
setup: func(accessProviderFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
accessProviderFileCreator.EXPECT().GetUserCount().Return(1).Once()
setup: func(identityStoreFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
identityStoreFileCreator.EXPECT().GetUserCount().Return(1).Once()
identityStoreFileCreator.EXPECT().Close().Return().Once()

identityStoreFileCreatorError = nil

Expand Down Expand Up @@ -115,8 +117,9 @@ func TestPostProcessor_PostProcess(t *testing.T) {
}, {
name: "a machine user",
fields: fields{
setup: func(accessProviderFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
accessProviderFileCreator.EXPECT().GetUserCount().Return(1).Once()
setup: func(identityStoreFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
identityStoreFileCreator.EXPECT().GetUserCount().Return(1).Once()
identityStoreFileCreator.EXPECT().Close().Return().Once()

identityStoreFileCreatorError = nil

Expand Down Expand Up @@ -152,8 +155,9 @@ func TestPostProcessor_PostProcess(t *testing.T) {
}, {
name: "two machine users and a normal user",
fields: fields{
setup: func(accessProviderFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
accessProviderFileCreator.EXPECT().GetUserCount().Return(3).Once()
setup: func(identityStoreFileCreator *mocks.IdentityStoreFileCreator) (identityStoreFileCreatorError error) {
identityStoreFileCreator.EXPECT().GetUserCount().Return(3).Once()
identityStoreFileCreator.EXPECT().Close().Return().Once()

identityStoreFileCreatorError = nil

Expand Down