service-core/test/application.integration.test.mjs
Jonatan Nilsson f008af597d
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed
Application almost done
2022-01-27 18:25:33 +00:00

46 lines
No EOL
1.6 KiB
JavaScript

import { Eltro as t, assert, stub } from 'eltro'
import fs from 'fs/promises'
import lowdb from '../core/db.mjs'
import Application from '../core/application.mjs'
import GitProvider from '../core/providers/git.mjs'
import Util from '../core/util.mjs'
const util = new Util(import.meta.url)
const logger = {
info: stub(),
warn: stub(),
error: stub(),
}
t.timeout(10000).describe('Application update integration test', function() {
let db
let app
let provider
t.before(function() {
return lowdb({ test: { } }, logger, util.getPathFromRoot('./db_test.json')).then(function(res) {
db = res
provider = new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/sc-helloworld/releases' })
app = new Application(util, db, provider, 'testapp')
return provider.getLatestVersion()
}).then(function(version) {
return fs.rm(`./test/testapp/${version.version}`, { force: true, recursive: true })
})
})
t.after(function() {
if (db.data.core.testapp.versions.length) {
return fs.rm(`./test/testapp/${db.data.core.testapp.versions[0].id}`, { force: true, recursive: true })
}
})
t.test('should run update and install correctly', async function(){
await app.update()
assert.ok(db.data.core.testapp.latestInstalled)
await fs.stat(util.getPathFromRoot(`./testapp/${db.data.core.testapp.latestInstalled}/index.mjs`))
await fs.stat(util.getPathFromRoot(`./testapp/${db.data.core.testapp.latestInstalled}/package.json`))
await fs.stat(util.getPathFromRoot(`./testapp/${db.data.core.testapp.latestInstalled}/node_modules`))
})
})