From ce046748b935b0e45070559d5a584d3ec9c6c551 Mon Sep 17 00:00:00 2001 From: Juri Leino Date: Thu, 27 Jul 2023 14:58:29 +0200 Subject: [PATCH] test(app): improve and extend tests --- test/tuttle.js | 87 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/test/tuttle.js b/test/tuttle.js index dfc56a2..a973b82 100644 --- a/test/tuttle.js +++ b/test/tuttle.js @@ -3,18 +3,85 @@ const chai = require('chai') const expect = chai.expect describe('Tuttle', function () { + // { + // "default": "tuttle-sample-data", + // "repos": { + // "repo": [ + // { + // "type": "github", + // "url": "https://github.com/eeditiones/tuttle-sample-data", + // "ref": "main", + // "collection": "tuttle-sample-data", + // "message": "", + // "status": "uptodate" + // }, + // { + // "type": "gitlab", + // "url": "", + // "ref": "master", + // "collection": "tuttle-sample-gitlab", + // "message": "gitlab error: Unauthorized", + // "status": "error" + // } + // ] + // } + // } + describe('git/status', function () { + let res + before(async function () { + res = await util.axios.get('git/status', {auth: util.adminCredentials}); + }); - it('Status', async function () { - const res = await util.axios.get('git/status', {auth: util.adminCredentials}); - - expect(res.status).to.equal(200); - }); + it('returns status 200', function () { + expect(res.status).to.equal(200); + }); + + it('default repo', function () { + expect(res.data.default).to.exist; + expect(res.data.default).to.equal('tuttle-sample-data'); + }); + + it('lists repos', function () { + expect(res.data.repos).to.exist; + expect(res.data.repos.repo).to.exist; + expect(res.data.repos.repo.length).to.be.greaterThan(0); + }); - it('Print Lockfile', async function () { - const res = await util.axios.get('git/lockfile', {auth: util.adminCredentials}); - - expect(res.status).to.equal(200); + it('github sample repo is up to date', function () { + expect(res.data.repos.repo[0]).to.deep.equal({ + "type": "github", + "url": "https://github.com/eeditiones/tuttle-sample-data", + "ref": "main", + "collection": "tuttle-sample-data", + "message": "", + "status": "uptodate" + }); + }); + + it('gitlab sample repo is not authorized', function () { + expect(res.data.repos.repo[1]).to.deep.equal({ + "type": "gitlab", + "url": "", + "ref": "master", + "collection": "tuttle-sample-gitlab", + "message": "gitlab error: Unauthorized", + "status": "error" + }); + }); }); + describe('git/lockfile', function () { + let res + before(async function () { + res = await util.axios.get('git/lockfile', {auth: util.adminCredentials}); + }); + + it('returns status 200', function () { + expect(res.status).to.equal(200); + }); -}) + it('confirms no lockfile to be present', function () { + expect(res.data.message).to.equal("lockfile not exist"); + }); + }); +});