Files
tstest/ts_tapbundle_serverside/classes.testfileprovider.ts

20 lines
776 B
TypeScript

import * as plugins from './plugins.js';
import * as paths from './paths.js';
export const fileUrls = {
dockerAlpineImage: 'https://code.foss.global/testassets/docker/raw/branch/main/alpine.tar',
}
export class TestFileProvider {
public async getDockerAlpineImageAsLocalTarball(): Promise<string> {
const filePath = plugins.path.join(paths.testFilesDir, 'alpine.tar')
// fetch the docker alpine image
const response = await plugins.smartrequest.SmartRequest.create()
.url(fileUrls.dockerAlpineImage)
.get();
await plugins.smartfsInstance.directory(paths.testFilesDir).recursive().create();
const buffer = Buffer.from(await response.arrayBuffer());
await plugins.smartfsInstance.file(filePath).write(buffer);
return filePath;
}
}