Skip to content

Commit b3507f5

Browse files
committed
test: initial testing
1 parent 077e189 commit b3507f5

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

src/core/domain/models/StorageDriver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export interface StorageDriver {
22
name: string
33
type: string
44
label: string
5-
directUpload: boolean
6-
directDownload: boolean
5+
directUpload?: boolean // Only present when getting the storage driver of a dataset
6+
directDownload?: boolean // Only present when getting the storage driver of a dataset
77
}

test/integration/datasets/DatasetsRepository.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,69 @@ describe('DatasetsRepository', () => {
14841484
})
14851485
})
14861486

1487+
describe('getDatasetStorageDriver', () => {
1488+
const testStorageDriverCollectionAlias = 'testDatasetStorageDriverCollection'
1489+
let testDatasetId: number
1490+
1491+
beforeAll(async () => {
1492+
await createCollectionViaApi(testStorageDriverCollectionAlias)
1493+
await publishCollectionViaApi(testStorageDriverCollectionAlias)
1494+
// await setStorageDriverViaApi(testStorageDriverCollectionAlias, 'LocalStack')
1495+
1496+
const { numericId } = await createDataset.execute(
1497+
TestConstants.TEST_NEW_DATASET_DTO,
1498+
testStorageDriverCollectionAlias
1499+
)
1500+
testDatasetId = numericId
1501+
})
1502+
1503+
afterAll(async () => {
1504+
await deleteUnpublishedDatasetViaApi(testDatasetId)
1505+
await deleteCollectionViaApi(testStorageDriverCollectionAlias)
1506+
})
1507+
1508+
test('should return correct storage driver', async () => {
1509+
const actual = await sut.getDatasetStorageDriver(testDatasetId)
1510+
1511+
console.log(actual)
1512+
1513+
expect(actual).toBeDefined()
1514+
expect(actual.name).toBe('local')
1515+
expect(actual.type).toBe('s3')
1516+
expect(actual.label).toBe('Local')
1517+
1518+
/*
1519+
1520+
-Ddataverse.files.localstack1.type=s3
1521+
-Ddataverse.files.localstack1.label=LocalStack
1522+
-Ddataverse.files.localstack1.upload-redirect=true
1523+
-Ddataverse.files.localstack1.download-redirect=true
1524+
{
1525+
name: 'localstack1',
1526+
type: 's3',
1527+
label: 'LocalStack',
1528+
directUpload: false,
1529+
directDownload: true
1530+
}
1531+
1532+
{
1533+
name: 'local',
1534+
type: 'file',
1535+
label: 'Local',
1536+
directUpload: false,
1537+
directDownload: false
1538+
}
1539+
1540+
*/
1541+
})
1542+
1543+
test('should return error when dataset does not exist', async () => {
1544+
await expect(sut.getDatasetStorageDriver(nonExistentTestDatasetId)).rejects.toBeInstanceOf(
1545+
ReadError
1546+
)
1547+
})
1548+
})
1549+
14871550
describe('getDatasetDownloadCount', () => {
14881551
const testGetDatasetDownloadCountCollectionAlias = 'testGetDatasetDownloadCountCollection'
14891552
let testDatasetIds: CreatedDatasetIdentifiers

0 commit comments

Comments
 (0)