fix(ci): Update CI workflows, repository URL, and apply minor code formatting fixes
This commit is contained in:
60
test/test.ts
60
test/test.ts
@ -14,7 +14,9 @@ let testZoneName = `test-zone-${randomPrefix}.com`;
|
||||
|
||||
// Basic initialization tests
|
||||
tap.test('should create a valid instance of CloudflareAccount', async () => {
|
||||
testCloudflareAccount = new cloudflare.CloudflareAccount(await testQenv.getEnvVarOnDemand('CF_KEY'));
|
||||
testCloudflareAccount = new cloudflare.CloudflareAccount(
|
||||
await testQenv.getEnvVarOnDemand('CF_KEY'),
|
||||
);
|
||||
expect(testCloudflareAccount).toBeTypeOf('object');
|
||||
expect(testCloudflareAccount.apiAccount).toBeTypeOf('object');
|
||||
});
|
||||
@ -22,12 +24,12 @@ tap.test('should create a valid instance of CloudflareAccount', async () => {
|
||||
tap.test('should preselect an account', async () => {
|
||||
await testCloudflareAccount.preselectAccountByName('Sandbox Account');
|
||||
expect(testCloudflareAccount.preselectedAccountId).toBeTypeOf('string');
|
||||
})
|
||||
});
|
||||
|
||||
// Zone management tests
|
||||
tap.test('.listZones() -> should list zones in account', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
const result = await testCloudflareAccount.convenience.listZones();
|
||||
// The test expects an array, but the current API might return an object with a result property
|
||||
@ -66,7 +68,7 @@ tap.test('ZoneManager: should get zone by name', async (tools) => {
|
||||
// DNS record tests
|
||||
tap.test('.listRecords(domainName) -> should list records for domain', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
const records = await testCloudflareAccount.convenience.listRecords('bleu.de');
|
||||
// The test expects an array, but the current API might return an object with a result property
|
||||
@ -94,7 +96,7 @@ tap.test('should create A record for subdomain', async (tools) => {
|
||||
subdomain,
|
||||
'A',
|
||||
'127.0.0.1',
|
||||
120
|
||||
120,
|
||||
);
|
||||
expect(result).toBeTypeOf('object');
|
||||
console.log(`Created A record for ${subdomain}`);
|
||||
@ -107,7 +109,7 @@ tap.test('should create CNAME record for subdomain', async (tools) => {
|
||||
subdomain,
|
||||
'CNAME',
|
||||
'example.com',
|
||||
120
|
||||
120,
|
||||
);
|
||||
expect(result).toBeTypeOf('object');
|
||||
console.log(`Created CNAME record for ${subdomain}`);
|
||||
@ -120,7 +122,7 @@ tap.test('should create TXT record for subdomain', async (tools) => {
|
||||
subdomain,
|
||||
'TXT',
|
||||
'v=spf1 include:_spf.example.com ~all',
|
||||
120
|
||||
120,
|
||||
);
|
||||
expect(result).toBeTypeOf('object');
|
||||
console.log(`Created TXT record for ${subdomain}`);
|
||||
@ -142,7 +144,7 @@ tap.test('should update A record content', async (tools) => {
|
||||
subdomain,
|
||||
'A',
|
||||
'192.168.1.1',
|
||||
120
|
||||
120,
|
||||
);
|
||||
expect(result).toBeTypeOf('object');
|
||||
expect(result.content).toEqual('192.168.1.1');
|
||||
@ -157,7 +159,7 @@ tap.test('should create A record for nested subdomain', async (tools) => {
|
||||
nestedSubdomain,
|
||||
'A',
|
||||
'127.0.0.5',
|
||||
120
|
||||
120,
|
||||
);
|
||||
expect(result).toBeTypeOf('object');
|
||||
console.log(`Created nested A record for ${nestedSubdomain}`);
|
||||
@ -179,7 +181,7 @@ tap.test('should update A record for nested subdomain', async (tools) => {
|
||||
nestedSubdomain,
|
||||
'A',
|
||||
'127.0.0.6',
|
||||
120
|
||||
120,
|
||||
);
|
||||
expect(result).toBeTypeOf('object');
|
||||
expect(result.content).toEqual('127.0.0.6');
|
||||
@ -209,14 +211,14 @@ tap.test('should remove A and CNAME records', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
const aSubdomain = `${randomPrefix}-a-test.bleu.de`;
|
||||
const cnameSubdomain = `${randomPrefix}-cname-test.bleu.de`;
|
||||
|
||||
|
||||
await testCloudflareAccount.convenience.removeRecord(aSubdomain, 'A');
|
||||
await testCloudflareAccount.convenience.removeRecord(cnameSubdomain, 'CNAME');
|
||||
|
||||
|
||||
// Verify records are removed
|
||||
const aRecord = await testCloudflareAccount.convenience.getRecord(aSubdomain, 'A');
|
||||
const cnameRecord = await testCloudflareAccount.convenience.getRecord(cnameSubdomain, 'CNAME');
|
||||
|
||||
|
||||
expect(aRecord).toBeUndefined();
|
||||
expect(cnameRecord).toBeUndefined();
|
||||
console.log(`Successfully removed A and CNAME records`);
|
||||
@ -232,7 +234,7 @@ tap.test('.purgeZone() -> should purge zone cache', async (tools) => {
|
||||
// Worker tests
|
||||
tap.test('should list workers', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
const workerArray = await testCloudflareAccount.workerManager.listWorkerScripts();
|
||||
expect(workerArray).toBeTypeOf('array');
|
||||
@ -246,7 +248,7 @@ tap.test('should list workers', async (tools) => {
|
||||
|
||||
tap.test('should create a worker', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
const worker = await testCloudflareAccount.workerManager.createWorker(
|
||||
testWorkerName,
|
||||
@ -254,13 +256,13 @@ tap.test('should create a worker', async (tools) => {
|
||||
event.respondWith(new Response('Hello from Cloudflare Workers!', {
|
||||
headers: { 'content-type': 'text/plain' }
|
||||
}))
|
||||
})`
|
||||
})`,
|
||||
);
|
||||
|
||||
|
||||
expect(worker).toBeTypeOf('object');
|
||||
expect(worker.id).toEqual(testWorkerName);
|
||||
console.log(`Created worker: ${testWorkerName}`);
|
||||
|
||||
|
||||
try {
|
||||
// Set routes for the worker
|
||||
await worker.setRoutes([
|
||||
@ -269,7 +271,7 @@ tap.test('should create a worker', async (tools) => {
|
||||
pattern: `https://${testWorkerName}.bleu.de/*`,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
console.log(`Set routes for worker ${testWorkerName}`);
|
||||
} catch (routeError) {
|
||||
console.error(`Error setting routes: ${routeError.message}`);
|
||||
@ -284,7 +286,7 @@ tap.test('should create a worker', async (tools) => {
|
||||
|
||||
tap.test('should get a specific worker by name', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
// First create a worker to ensure it exists
|
||||
await testCloudflareAccount.workerManager.createWorker(
|
||||
@ -293,12 +295,12 @@ tap.test('should get a specific worker by name', async (tools) => {
|
||||
event.respondWith(new Response('Hello from Cloudflare Workers!', {
|
||||
headers: { 'content-type': 'text/plain' }
|
||||
}))
|
||||
})`
|
||||
})`,
|
||||
);
|
||||
|
||||
|
||||
// Now get the worker
|
||||
const worker = await testCloudflareAccount.workerManager.getWorker(testWorkerName);
|
||||
|
||||
|
||||
expect(worker).toBeTypeOf('object');
|
||||
expect(worker?.id).toEqual(testWorkerName);
|
||||
console.log(`Successfully retrieved worker: ${testWorkerName}`);
|
||||
@ -311,17 +313,17 @@ tap.test('should get a specific worker by name', async (tools) => {
|
||||
|
||||
tap.test('should update worker script', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
const worker = await testCloudflareAccount.workerManager.getWorker(testWorkerName);
|
||||
|
||||
|
||||
if (worker) {
|
||||
await worker.updateScript(`addEventListener('fetch', event => {
|
||||
event.respondWith(new Response('Updated Worker Script!', {
|
||||
headers: { 'content-type': 'text/plain' }
|
||||
}))
|
||||
})`);
|
||||
|
||||
|
||||
console.log(`Updated script for worker ${testWorkerName}`);
|
||||
expect(true).toBeTrue();
|
||||
} else {
|
||||
@ -338,10 +340,10 @@ tap.test('should update worker script', async (tools) => {
|
||||
|
||||
tap.test('should delete the test worker', async (tools) => {
|
||||
tools.timeout(600000);
|
||||
|
||||
|
||||
try {
|
||||
const worker = await testCloudflareAccount.workerManager.getWorker(testWorkerName);
|
||||
|
||||
|
||||
if (worker) {
|
||||
const result = await worker.delete();
|
||||
console.log(`Deleted worker: ${testWorkerName}`);
|
||||
@ -381,4 +383,4 @@ tap.test('should format TTL values', async () => {
|
||||
expect(cloudflare.CloudflareUtils.formatTtl(999)).toEqual('999 seconds');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user