-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added getCollection unit tests, added docker-compose changes from Jim…
…, removed placeholder content
- Loading branch information
Matt Mangan
committed
Mar 14, 2024
1 parent
80973c8
commit c61e99d
Showing
15 changed files
with
66 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Collection } from '../models/Collection' | ||
export interface ICollectionsRepository { | ||
getCollection(collectionId: string): Promise<Collection> | ||
getCollection(collectionId: number | string): Promise<Collection> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,10 @@ | ||
import { GetCollection } from './domain/useCases/GetCollection' | ||
// TODO | ||
// import { GetCollectionRoles } from "./domain/useCases/getCollectionRoles"; | ||
// import { GetCollectionIsRoot } from "./domain/useCases/getCollectionIsRoot"; | ||
// import { GetCollectionFacets } from "./domain/useCases/getCollectionFacets"; | ||
// import { GetCollectionMetadata } from "./domain/useCases/getCollectionMetadata"; | ||
// import { GetCollectionStorageSize } from "./domain/useCases/getCollectionStorageSize"; | ||
// import { GetCollectionMetadataBlocks } from "./domain/useCases/getCollectionMetadataBlocks"; | ||
// import { GetCollectionRolesAssignments } from "./domain/useCases/getCollectionRolesAssignments"; | ||
|
||
import { CollectionsRepository } from './infra/repositories/CollectionsRepository' | ||
|
||
const collectionsRepository = new CollectionsRepository() | ||
|
||
const getCollection = new GetCollection(collectionsRepository) | ||
|
||
// const getCollectionRoles = new GetCollectionRoles(collectionsRepository) | ||
// const getCollectionIsRoot = new GetCollectionIsRoot(collectionsRepository) | ||
// const getCollectionFacets = new GetCollectionFacets(collectionsRepository) | ||
// const getCollectionMetadata = new GetCollectionMetadata(collectionsRepository) | ||
// const getCollectionStorageSize = new GetCollectionStorageSize(collectionsRepository) | ||
// const getCollectionMetadataBlocks = new GetCollectionMetadataBlocks(collectionsRepository) | ||
// const getCollectionRolesAssignments = new GetCollectionRolesAssignments(collectionsRepository) | ||
|
||
export { | ||
getCollection | ||
// TODO | ||
// getCollectionRoles() | ||
// getCollectionIsRoot() | ||
// getCollectionFacets() | ||
// getCollectionMetadata() | ||
// getCollectionStorageSize() | ||
// getCollectionMetadataBlocks() | ||
// getCollectionRolesAssignments() | ||
} | ||
export { Collection, CollectionType, CollectionContacts } from './domain/models/Collection' | ||
export { getCollection } | ||
export { Collection } from './domain/models/Collection' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
POSTGRES_VERSION=13 | ||
DATAVERSE_DB_USER=dataverse | ||
SOLR_VERSION=9.3.0 | ||
DATAVERSE_IMAGE_REGISTRY=ghcr.io | ||
DATAVERSE_IMAGE_TAG=10286-add-owner-info | ||
# DATAVERSE_IMAGE_REGISTRY=docker.io | ||
# DATAVERSE_IMAGE_TAG=unstable | ||
DATAVERSE_IMAGE_REGISTRY=docker.io | ||
DATAVERSE_IMAGE_TAG=unstable | ||
DATAVERSE_BOOTSTRAP_TIMEOUT=5m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
// import { Collection } from "../../../src/collections"; | ||
// import axios, { AxiosResponse } from "axios"; | ||
// import { TestConstants } from "../TestConstants"; | ||
// import { CollectionPayload } from "../../../src/collections/infra/repositories/transformers/CollectionPayload"; | ||
// import TurndownService from 'turndown' | ||
import { Collection } from '../../../src/collections' | ||
|
||
// const turndownService = new TurndownService() | ||
// const COLLECTION_ID_STR = 'x' | ||
// const COLLECTION_NAME_STR = '' | ||
// const COLLECTION_ALIAS_STR = 'firstCollection' | ||
// const COLLECTION_AFFILIATION_STR = '' | ||
// const COLLECTION_API_REQUEST_HEADERS = { | ||
// headers: { 'Content-Type': 'application/json', 'X-Dataverse-Key': process.env.TEST_API_KEY } | ||
// } | ||
const COLLECTION_ID = 11111 | ||
const COLLECTION_NAME_STR = 'Laboratory Research' | ||
const COLLECTION_ALIAS_STR = 'secondCollection' | ||
const COLLECTION_AFFILIATION_STR = 'Laboratory Research Corporation' | ||
|
||
export const createCollectionModel = (): Collection => { | ||
const collectionModel: Collection = { | ||
id: COLLECTION_ID, | ||
name: COLLECTION_NAME_STR, | ||
alias: COLLECTION_ALIAS_STR, | ||
affiliation: COLLECTION_AFFILIATION_STR | ||
} | ||
return collectionModel | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"id": 11111, | ||
"name": "Scientific Research", | ||
"alias": "firstCollection", | ||
"dataverseContacts": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { GetCollection } from '../../../src/collections/domain/useCases/GetCollection' | ||
import { ICollectionsRepository } from '../../../src/collections/domain/repositories/ICollectionsRepository' | ||
import { ReadError } from '../../../src' | ||
import { createCollectionModel } from '../../testHelpers/collections/collectionHelper' | ||
|
||
describe('execute', () => { | ||
test('should return collection on repository success', async () => { | ||
const testCollection = createCollectionModel() | ||
const collectionRepositoryStub: ICollectionsRepository = {} as ICollectionsRepository | ||
collectionRepositoryStub.getCollection = jest.fn().mockResolvedValue(testCollection) | ||
const testGetCollection = new GetCollection(collectionRepositoryStub) | ||
|
||
const actual = await testGetCollection.execute(1) | ||
|
||
expect(actual).toEqual(testCollection) | ||
}) | ||
|
||
test('should return error result on repository error', async () => { | ||
const collectionRepositoryStub: ICollectionsRepository = {} as ICollectionsRepository | ||
collectionRepositoryStub.getCollection = jest.fn().mockRejectedValue(new ReadError()) | ||
const testGetCollection = new GetCollection(collectionRepositoryStub) | ||
|
||
await expect(testGetCollection.execute(1)).rejects.toThrow(ReadError) | ||
}) | ||
}) |