fix(webdav-client): correct directory listing path handling and update tooling for current package dependencies
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartwebdav from '../ts/index.js';
|
||||
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as qenv from '@push.rocks/qenv';
|
||||
|
||||
let webdavClient: smartwebdav.WebdavClient;
|
||||
const testQenv = new qenv.Qenv('./', './.nogit/');
|
||||
|
||||
const requireEnv = async (envNameArg: string): Promise<string> => {
|
||||
const envValue = await testQenv.getEnvVarOnDemand(envNameArg);
|
||||
if (!envValue) {
|
||||
throw new Error(`Missing required environment variable: ${envNameArg}`);
|
||||
}
|
||||
return envValue;
|
||||
};
|
||||
|
||||
tap.test('should run WebDAV integration flow', async () => {
|
||||
if (process.env.SMARTWEBDAV_RUN_INTEGRATION_TESTS !== 'true') {
|
||||
console.log('Skipping WebDAV integration test. Set SMARTWEBDAV_RUN_INTEGRATION_TESTS=true to run it.');
|
||||
return;
|
||||
}
|
||||
|
||||
webdavClient = new smartwebdav.WebdavClient({
|
||||
serverUrl: await requireEnv('SERVER_URL'),
|
||||
authType: smartwebdav.authType.Password,
|
||||
password: await requireEnv('SERVER_TOKEN'),
|
||||
});
|
||||
|
||||
const directoryListed = await webdavClient.listDirectory('/testdir');
|
||||
console.log(directoryListed);
|
||||
|
||||
const smartfileFactory = new smartfile.SmartFileFactory(undefined);
|
||||
const smartfile1 = smartfileFactory.fromString('./testdir/so/awesome/hello.txt', 'hello there', 'utf8');
|
||||
const smartfile2 = smartfileFactory.fromString('./testdir/so/awesome/hello2.txt', 'hello there 2', 'utf8');
|
||||
|
||||
await webdavClient.uploadSmartFileArray([smartfile1, smartfile2]);
|
||||
await webdavClient.ensureDirectory('/testdir/another/dirctory');
|
||||
await webdavClient.deleteDirectory('/testdir/another');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
@@ -1,36 +0,0 @@
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import * as smartwebdav from '../ts/index.js'
|
||||
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as qenv from '@push.rocks/qenv';
|
||||
const testQenv = new qenv.Qenv('./', './.nogit/');
|
||||
|
||||
let webdavClient: smartwebdav.WebdavClient;
|
||||
|
||||
tap.test('should', async () => {
|
||||
webdavClient = new smartwebdav.WebdavClient({
|
||||
serverUrl: await testQenv.getEnvVarOnDemand('SERVER_URL'),
|
||||
authType: smartwebdav.authType.Password,
|
||||
password: await testQenv.getEnvVarOnDemand('SERVER_TOKEN'),
|
||||
});
|
||||
|
||||
const directoryListed = await webdavClient.listDirectory('/testdir');
|
||||
console.log(directoryListed);
|
||||
});
|
||||
|
||||
tap.test('should upload smartfiles', async () => {
|
||||
const smartfile1 = await smartfile.SmartFile.fromString('./testdir/so/awesome/hello.txt', 'hello there', 'utf8');
|
||||
const smartfile2 = await smartfile.SmartFile.fromString('./testdir/so/awesome/hello2.txt', 'hello there 2', 'utf8');
|
||||
|
||||
await webdavClient.uploadSmartFileArray([smartfile1, smartfile2]);
|
||||
});
|
||||
|
||||
tap.test('should ensure directory', async () => {
|
||||
await webdavClient.ensureDirectory('/testdir/another/dirctory');
|
||||
})
|
||||
|
||||
tap.test('should delete a directory', async () => {
|
||||
await webdavClient.deleteDirectory('/testdir/another');
|
||||
})
|
||||
|
||||
export default tap.start()
|
||||
Reference in New Issue
Block a user