Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkhala committed Dec 28, 2023
1 parent 81ce3c9 commit fc9ed0e
Showing 1 changed file with 44 additions and 36 deletions.
80 changes: 44 additions & 36 deletions light/test/devopsTest.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
import {consoleLogger} from '@davidkhala/logger/log4.js';
import assert from 'assert';
import {homeResolve} from '../path.js';
import {execStream, hostname, ip, tempdir, execSync, os, uid} from '../devOps.js';
import {homeResolve,} from '../path.js';
import {execStream, hostname, ip, tempdir, execSync, os, uid, homedir} from '../devOps.js';
import OS from 'os'
import Path from 'path'

const logger = consoleLogger('devops');

describe('devOps', function () {

this.timeout(0);
if (os.platform === 'linux' && !process.env.CI) {
it('exec: apt update', () => {
execSync('sudo apt update');
// Test passed: sudo have interactive input
// Test failed: on Oracle Linux 8
});
}
this.timeout(0);
if (os.platform === 'linux' && !process.env.CI) {
it('exec: apt update', () => {
execSync('sudo apt update');
// Test passed: sudo have interactive input
// Test failed: on Oracle Linux 8
});
}

it('execStream: npm i', () => {
execStream('npm install');
});
it('tempdir', () => {
logger.info({tempdir});
switch (os.platform) {
case 'win32':
assert.equal(tempdir, homeResolve('AppData', 'Local', 'Temp'));
break;
case 'linux':
assert.equal(tempdir, '/tmp');
}
it('execStream: npm i', () => {
execStream('npm install');
});
it('tempdir', () => {
logger.info({tempdir});
switch (os.platform) {
case 'win32':
const {username, homedir} = OS.userInfo()
console.debug({homedir})
let expectedTEMPRoot = homedir
if (username.length > 6) {
expectedTEMPRoot = homedir.replaceAll(username, `${username.toUpperCase()}~1`)
}
assert.equal(tempdir, Path.resolve(expectedTEMPRoot, 'AppData', 'Local', 'Temp'));
break;
case 'linux':
assert.equal(tempdir, '/tmp');
}

});
it('ip', () => {
const address = ip(true);
assert.ok(Array.isArray(address));
});
it('hostname', () => {
logger.info({hostname});
});
it('os', () => {
logger.info(os);
});
it('uid', () => {
logger.info({uid});
});
});
it('ip', () => {
const address = ip(true);
assert.ok(Array.isArray(address));
});
it('hostname', () => {
logger.info({hostname});
});
it('os', () => {
logger.info(os);
});
it('uid', () => {
logger.info({uid});
});
});

1 comment on commit fc9ed0e

@davidkhala
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #19

Please sign in to comment.