Skip to content

Commit

Permalink
fix: remove slash behavior in resolveTemplate
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Lundkvist <[email protected]>
  • Loading branch information
Lunkers committed Jan 20, 2025
1 parent 5a5716b commit a132282
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
32 changes: 20 additions & 12 deletions src/encorePackager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import {
EncorePackager,
parseInputsFromEncoreJob
} from './encorePackager';
import { DEFAULT_STREAM_KEY_TEMPLATES, PackagingConfig } from './config';
import {
DEFAULT_OUTPUT_SUBFOLDER_TEMPLATE,
DEFAULT_STREAM_KEY_TEMPLATES,
PackagingConfig
} from './config';

const job: EncoreJob = {
externalId: 'external-id',
id: 'e5e76304-744c-41d6-85f7-69007b3b1a65',
status: 'SUCCESSFUL',
output: [
Expand Down Expand Up @@ -148,23 +153,26 @@ describe('Test parseInputsFromEncoreJob', () => {
});

describe('Test EncorePackager file system methods', () => {
const config = {
outputFolder: 's3://bucket-name/prefix/',
outputSubfolderTemplate: '$EXTERNALID$/$INPUTNAME$/$JOBID$',
concurrency: 1
} as PackagingConfig;
const encorePackager = new EncorePackager(config);
it('Uses the first input for templating', () => {
it("Doesn't use external ID if the template does not include it", () => {
const config = {
outputFolder: 's3://bucket-name/prefix/',
outputSubfolderTemplate: DEFAULT_OUTPUT_SUBFOLDER_TEMPLATE,
concurrency: 1
} as PackagingConfig;
const encorePackager = new EncorePackager(config);
const destination = encorePackager.getPackageDestination(job);
expect(destination).toEqual(
's3://bucket-name/prefix/test-asset/e5e76304-744c-41d6-85f7-69007b3b1a65'
);
});
it('Uses the external ID for templating when present', () => {
const destination = encorePackager.getPackageDestination({
...job,
externalId: 'external-id'
});
const config = {
outputFolder: 's3://bucket-name/prefix/',
outputSubfolderTemplate: '$EXTERNALID$/$INPUTNAME$/$JOBID$',
concurrency: 1
} as PackagingConfig;
const encorePackager = new EncorePackager(config);
const destination = encorePackager.getPackageDestination(job);
expect(destination).toEqual(
's3://bucket-name/prefix/external-id/test-asset/e5e76304-744c-41d6-85f7-69007b3b1a65'
);
Expand Down
2 changes: 1 addition & 1 deletion src/encorePackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class EncorePackager {
const inputUri = job.inputs[0].uri;
const inputBasename = basename(inputUri, extname(inputUri));
return template
.replaceAll('$EXTERNALID$/', job.externalId ? job.externalId + '/' : '')
.replaceAll('$EXTERNALID$', job.externalId ? job.externalId : '')
.replaceAll('$JOBID$', job.id)
.replaceAll('$INPUTNAME$', inputBasename);
}
Expand Down

0 comments on commit a132282

Please sign in to comment.