Fix TechDocs common bug (and tests) on windows.

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-10-26 17:41:53 +02:00
parent e33d8313ad
commit cfd54b9af4
3 changed files with 9 additions and 15 deletions
@@ -334,15 +334,12 @@ describe('AwsS3Publish', () => {
name: 'path',
};
const techDocsMetadaFilePath = path.posix.join(
...Object.values(invalidEntityName),
'techdocs_metadata.json',
);
const fails = publisher.fetchTechDocsMetadata(invalidEntityName);
await expect(fails).rejects.toMatchObject({
message: `TechDocs metadata fetch failed; caused by Error: The file ${techDocsMetadaFilePath} does not exist!`,
message: expect.stringMatching(
/TechDocs metadata fetch failed; caused by Error: The file .* does not exist/i,
),
});
});
});
@@ -332,15 +332,10 @@ describe('GoogleGCSPublish', () => {
name: 'path',
};
const techDocsMetadaFilePath = path.posix.join(
...Object.values(invalidEntityName),
'techdocs_metadata.json',
);
const fails = publisher.fetchTechDocsMetadata(invalidEntityName);
await expect(fails).rejects.toMatchObject({
message: `The file ${techDocsMetadaFilePath} does not exist!`,
message: expect.stringMatching(/The file .* does not exist/i),
});
});
});
@@ -198,10 +198,12 @@ export const getCloudPathForLocalPath = (
? relativeFilePathTriplet
: lowerCaseEntityTriplet(relativeFilePathTriplet);
const destinationWithRoot = path.join(
...externalStorageRootPath.split(path.posix.sep),
// Again, the / delimiter is intentional, as it represents remote storage.
const destinationWithRoot = [
// The extra filter prevents unintended double slashes and prefixes.
...externalStorageRootPath.split(path.posix.sep).filter(s => s !== ''),
destination,
);
].join('/');
return destinationWithRoot; // Remote storage file relative path
};