fix(core): update

This commit is contained in:
Philipp Kunz 2020-09-30 17:06:26 +00:00
parent 5e5bb3032c
commit 8b6021ff66

View File

@ -6,64 +6,62 @@ let testDockerHost: docker.DockerHost;
if (process.env.CI) { if (process.env.CI) {
tap.test('ci placeholder', async () => {}); tap.test('ci placeholder', async () => {});
tap.start(); tap.start();
process.exit(0); } else {
} tap.test('should create a new Dockersock instance', async () => {
tap.test('should create a new Dockersock instance', async () => {
testDockerHost = new docker.DockerHost('http://unix:/var/run/docker.sock:'); testDockerHost = new docker.DockerHost('http://unix:/var/run/docker.sock:');
return expect(testDockerHost).to.be.instanceof(docker.DockerHost); return expect(testDockerHost).to.be.instanceof(docker.DockerHost);
}); });
tap.test('should create a docker swarm', async () => { tap.test('should create a docker swarm', async () => {
await testDockerHost.activateSwarm(); await testDockerHost.activateSwarm();
}); });
// Containers // Containers
tap.test('should list containers', async () => { tap.test('should list containers', async () => {
const containers = await testDockerHost.getContainers(); const containers = await testDockerHost.getContainers();
console.log(containers); console.log(containers);
}); });
// Networks // Networks
tap.test('should list networks', async () => { tap.test('should list networks', async () => {
const networks = await testDockerHost.getNetworks(); const networks = await testDockerHost.getNetworks();
console.log(networks); console.log(networks);
}); });
tap.test('should create a network', async () => { tap.test('should create a network', async () => {
const newNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, { const newNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
Name: 'webgateway', Name: 'webgateway',
}); });
expect(newNetwork).to.be.instanceOf(docker.DockerNetwork); expect(newNetwork).to.be.instanceOf(docker.DockerNetwork);
expect(newNetwork.Name).to.equal('webgateway'); expect(newNetwork.Name).to.equal('webgateway');
}); });
tap.test('should remove a network', async () => { tap.test('should remove a network', async () => {
const webgateway = await docker.DockerNetwork.getNetworkByName(testDockerHost, 'webgateway'); const webgateway = await docker.DockerNetwork.getNetworkByName(testDockerHost, 'webgateway');
await webgateway.remove(); await webgateway.remove();
}); });
// Images // Images
tap.test('should pull an image from imagetag', async () => { tap.test('should pull an image from imagetag', async () => {
const image = await docker.DockerImage.createFromRegistry(testDockerHost, { const image = await docker.DockerImage.createFromRegistry(testDockerHost, {
imageUrl: 'hosttoday/ht-docker-node', imageUrl: 'hosttoday/ht-docker-node',
imageTag: 'alpine', imageTag: 'alpine',
}); });
expect(image).to.be.instanceOf(docker.DockerImage); expect(image).to.be.instanceOf(docker.DockerImage);
console.log(image); console.log(image);
}); });
tap.test('should return a change Observable', async (tools) => { tap.test('should return a change Observable', async (tools) => {
const testObservable = await testDockerHost.getEventObservable(); const testObservable = await testDockerHost.getEventObservable();
const subscription = testObservable.subscribe((changeObject) => { const subscription = testObservable.subscribe((changeObject) => {
console.log(changeObject); console.log(changeObject);
}); });
await tools.delayFor(2000); await tools.delayFor(2000);
subscription.unsubscribe(); subscription.unsubscribe();
}); });
// SECRETS // SECRETS
tap.test('should create a secret', async () => { tap.test('should create a secret', async () => {
const mySecret = await docker.DockerSecret.createSecret(testDockerHost, { const mySecret = await docker.DockerSecret.createSecret(testDockerHost, {
name: 'testSecret', name: 'testSecret',
version: '1.0.3', version: '1.0.3',
@ -71,24 +69,24 @@ tap.test('should create a secret', async () => {
labels: {}, labels: {},
}); });
console.log(mySecret); console.log(mySecret);
}); });
tap.test('should remove a secret by name', async () => { tap.test('should remove a secret by name', async () => {
const mySecret = await docker.DockerSecret.getSecretByName(testDockerHost, 'testSecret'); const mySecret = await docker.DockerSecret.getSecretByName(testDockerHost, 'testSecret');
await mySecret.remove(); await mySecret.remove();
}); });
// SERVICES // SERVICES
tap.test('should activate swarm mode', async () => { tap.test('should activate swarm mode', async () => {
await testDockerHost.activateSwarm(); await testDockerHost.activateSwarm();
}); });
tap.test('should list all services', async (tools) => { tap.test('should list all services', async (tools) => {
const services = await testDockerHost.getServices(); const services = await testDockerHost.getServices();
console.log(services); console.log(services);
}); });
tap.test('should create a service', async () => { tap.test('should create a service', async () => {
const testNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, { const testNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
Name: 'testNetwork', Name: 'testNetwork',
}); });
@ -114,6 +112,7 @@ tap.test('should create a service', async () => {
await testService.remove(); await testService.remove();
await testNetwork.remove(); await testNetwork.remove();
await testSecret.remove(); await testSecret.remove();
}); });
tap.start(); tap.start();
}