2024-01-29 12:55:55 +00:00
|
|
|
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
2024-02-17 20:55:25 +00:00
|
|
|
import * as hetznercloud from '../ts/index.js';
|
|
|
|
import * as qenv from '@push.rocks/qenv';
|
|
|
|
const testQenv = new qenv.Qenv('./', './.nogit/');
|
2024-01-29 12:55:55 +00:00
|
|
|
|
2024-02-17 20:55:25 +00:00
|
|
|
let testAccount: hetznercloud.HetznerAccount;
|
|
|
|
|
|
|
|
tap.test('should create a valid hetzer account', async () => {
|
|
|
|
testAccount = new hetznercloud.HetznerAccount(await testQenv.getEnvVarOnDemand('HETZNER_API_TOKEN'));
|
|
|
|
expect(testAccount).toBeInstanceOf(hetznercloud.HetznerAccount);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should be able to list all servers', async () => {
|
|
|
|
const servers = await testAccount.getServers();
|
|
|
|
expect(servers).toBeArray();
|
|
|
|
console.log(JSON.stringify(servers, null, 2));
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('should be able to create a server', async () => {
|
|
|
|
const newServer = await testAccount.createServer({
|
|
|
|
name: 'testserver',
|
|
|
|
location: 'nbg1'
|
|
|
|
});
|
|
|
|
expect(newServer).toBeInstanceOf(hetznercloud.HetznerServer);
|
|
|
|
console.log(newServer);
|
2024-01-29 12:55:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
tap.start()
|