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

Fix stream #8

Merged
merged 4 commits into from
Jun 9, 2023
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
4 changes: 2 additions & 2 deletions app/processing/get-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const download = async (fileName, directoryName, shareName) => {
const share = shareServiceClient.getShareClient(shareName)
const directory = share.getDirectoryClient(directoryName)
const file = directory.getFileClient(fileName)
const downloaded = await file.download()
const downloaded = await file.downloadToBuffer()
console.log(`Found ${fileName}`)
return downloaded.readableStreamBody
return downloaded.toString()
}

module.exports = getFile
4 changes: 2 additions & 2 deletions app/processing/transfer-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const getFile = require('./get-file')
const writeFile = require('./write-file')

const transferFile = async (fileName, directoryName, shareName) => {
const file = await getFile(fileName, directoryName, shareName)
await writeFile(fileName, file)
const fileContent = await getFile(fileName, directoryName, shareName)
await writeFile(fileName, fileContent)
await deleteFile(fileName, directoryName, shareName)
console.log(`Successfully transferred ${fileName}`)
}
Expand Down
24 changes: 15 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-pay-file-receiver",
"version": "1.0.6",
"version": "1.0.7",
"description": "Transfer files from DAX",
"homepage": "https://github.com/DEFRA/ffc-pay-file-receiver",
"main": "app/index.js",
Expand Down
10 changes: 5 additions & 5 deletions test/integration/narrow/app/storage/get-container.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ jest.mock('../../../../../app/config/get-storage-config')
const getStorageConfig = require('../../../../../app/config/get-storage-config')
const { getContainer } = require('../../../../../app/storage/get-container')

let retreivedGetStorageConfig
let retrievedGetStorageConfig

describe('get container object', () => {
beforeEach(() => {
retreivedGetStorageConfig = JSON.parse(JSON.stringify(require('../../../../mocks/storage-config')))
getStorageConfig.mockResolvedValue(retreivedGetStorageConfig)
retrievedGetStorageConfig = JSON.parse(JSON.stringify(require('../../../../mocks/storage-config')))
getStorageConfig.mockResolvedValue(retrievedGetStorageConfig)
})

afterEach(() => {
jest.clearAllMocks()
})

test('should call getStorageConfig', async () => {
retreivedGetStorageConfig.useBlobConnectionStr = true
getStorageConfig.mockResolvedValue(retreivedGetStorageConfig)
retrievedGetStorageConfig.useBlobConnectionStr = true
getStorageConfig.mockResolvedValue(retrievedGetStorageConfig)
await getContainer()
expect(getStorageConfig).toHaveBeenCalled()
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/processing/get-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mockStorageConfig = require('../../mocks/storage-config')
const mockDelete = jest.fn()

const mockGetFileClient = {
download: jest.fn().mockResolvedValue({ readableStreamBody: mockFileContent }),
downloadToBuffer: jest.fn().mockResolvedValue(mockFileContent),
delete: mockDelete
}
const mockGetDirectoryClient = {
Expand Down