From 7cc81ab249529d68bce07cf30d7f74550be4a5c3 Mon Sep 17 00:00:00 2001 From: Jamie Slome Date: Fri, 10 May 2024 10:40:54 +0100 Subject: [PATCH] test: verify that .remote folder is purged and timestamp instance of local clone #550 --- test/testClearBareClone.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/testClearBareClone.test.js diff --git a/test/testClearBareClone.test.js b/test/testClearBareClone.test.js new file mode 100644 index 00000000..c600610c --- /dev/null +++ b/test/testClearBareClone.test.js @@ -0,0 +1,26 @@ +const fs = require('fs'); +const chai = require('chai'); +const clearBareClone = require('../src/proxy/processors/push-action/clearBareClone').exec; +const pullRemote = require('../src/proxy/processors/push-action/pullRemote').exec; +const { Action } = require('../src/proxy/actions/Action'); +chai.should(); + +const expect = chai.expect; +const timestamp = Date.now(); + +describe('clear bare and local clones', async () => { + it('pull remote generates a local .remote folder', async () => { + const action = new Action('123', 'type', 'get', timestamp, 'finos/git-proxy'); + action.url = 'https://github.com/finos/git-proxy'; + await pullRemote({}, action); + + expect(fs.existsSync(`./.remote/${timestamp}`)).to.be.true; + }); + + it('clear bare clone function purges .remote folder and specific clone folder', async () => { + const action = new Action('123', 'type', 'get', timestamp, 'finos/git-proxy'); + await clearBareClone(null, action); + expect(fs.existsSync(`./.remote`)).to.throw; + expect(fs.existsSync(`./.remote/${timestamp}`)).to.throw; + }); +});