-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
N21-2103 vidis-sync service unit test
- Loading branch information
1 parent
9651e8a
commit 7ce3274
Showing
7 changed files
with
163 additions
and
23 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
9 changes: 9 additions & 0 deletions
9
apps/server/src/infra/sync/media-licenses/testing/vidis.response.factory.ts
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,9 @@ | ||
import { Factory } from 'fishery'; | ||
import { VidisResponse } from '../response'; | ||
import { vidisItemResponseFactory } from './vidis-item.response.factory'; | ||
|
||
export const vidisResponseFactory = Factory.define<VidisResponse>(() => { | ||
return { | ||
items: vidisItemResponseFactory.buildList(3), | ||
}; | ||
}); |
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
17 changes: 17 additions & 0 deletions
17
apps/server/src/modules/media-source/testing/media-source-basic-auth-config.factory.ts
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,17 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { BaseFactory } from '@shared/testing'; | ||
import { MediaSourceBasicAuthConfig, MediaSourceBasicAuthConfigProps } from '../domain'; | ||
|
||
export const mediaSourceBasicAuthConfigFactory = BaseFactory.define< | ||
MediaSourceBasicAuthConfig, | ||
MediaSourceBasicAuthConfigProps | ||
>(MediaSourceBasicAuthConfig, ({ sequence }) => { | ||
const config: MediaSourceBasicAuthConfigProps = { | ||
id: new ObjectId().toHexString(), | ||
username: `media-source-user-${sequence}`, | ||
password: `media-source-password-${sequence}`, | ||
authEndpoint: 'https://media-source-endpoint.com/test', | ||
}; | ||
|
||
return config; | ||
}); |
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
24 changes: 19 additions & 5 deletions
24
apps/server/src/modules/media-source/testing/media-source.factory.ts
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,17 +1,31 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { BaseFactory } from '@shared/testing'; | ||
import { MediaSourceProps, MediaSource } from '@src/modules/media-source/domain'; | ||
import { DeepPartial } from 'fishery'; | ||
import { MediaSourceProps, MediaSource } from '../domain'; | ||
import { MediaSourceDataFormat } from '../enum'; | ||
import { mediaSourceOauthConfigFactory } from './media-source-oauth-config.factory'; | ||
import { mediaSourceBasicAuthConfigFactory } from './media-source-basic-auth-config.factory'; | ||
|
||
import { MediaSourceDataFormat } from '@src/modules/media-source/enum'; | ||
class MediaSourceFactory extends BaseFactory<MediaSource, MediaSourceProps> { | ||
public withBasicAuthConfig(): this { | ||
const params: DeepPartial<MediaSourceProps> = { basicAuthConfig: mediaSourceBasicAuthConfigFactory.build() }; | ||
|
||
import { mediaSourceConfigFactory } from './media-source-config.factory'; | ||
return this.params(params); | ||
} | ||
|
||
export const mediaSourceFactory = BaseFactory.define<MediaSource, MediaSourceProps>(MediaSource, ({ sequence }) => { | ||
public withOauthConfig(): this { | ||
const params: DeepPartial<MediaSourceProps> = { oauthConfig: mediaSourceOauthConfigFactory.build() }; | ||
|
||
return this.params(params); | ||
} | ||
} | ||
|
||
export const mediaSourceFactory = MediaSourceFactory.define(MediaSource, ({ sequence }) => { | ||
return { | ||
id: new ObjectId().toHexString(), | ||
name: `media-source-${sequence}`, | ||
sourceId: `source-id-${sequence}`, | ||
format: MediaSourceDataFormat.BILDUNGSLOGIN, | ||
oauthConfig: mediaSourceConfigFactory.build(), | ||
oauthConfig: mediaSourceOauthConfigFactory.build(), | ||
}; | ||
}); |