import Ssh from '../src/ssh' import to from 'await-to-js' import { expect } from 'chai' import { it } from 'mocha' import logger from '@uci/logger' describe('SSH Class Testing ',async ()=> { let remote let log before(async () => { log = logger({ name: 'remote-code', test:'/test/ssh.test.js', class:'Ssh', file:'src/ssh.js', id: 'testing' }) remote = new Ssh() await remote.configure('./test/config/ssh') // will pick up config file format log.info(`making connection to ${remote.opts.host}`) let [err] = await to(remote.connect()) if (err) { log.info('unable to connect aborting test', err) return err } log.info('ready for testing') }) after(async () => { remote.close() }) it('simple connect and reply to "cd /opt && pwd"' , async function () { let [err,res] = await to(remote.exec('cd /opt && pwd')) if (err) { log.info('error running command aborting test', err) return } log.info({remoteHost:remote.opts.host, reply:res.reply.toString().trim(), err:err, cmd:res.command, msg:`remote command completed ${res.command}`}) expect(res.reply.toString().trim(), 'test failed').to.equal('/opt') }) }) // function hooks(remote) { // // // beforeEach(async() => { // // await someasyncfunctiontodobeforeeachtest() // // }) // // // after(async() => { // // await someasyncfunctiontodoaftereeachtest() // // }) // // }