1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import { describe, it } from "mocha";
-
- import { Updater, rmrf } from '../Index'
-
- const testFolder = "CLONED_TEST_REPO"
-
- describe('Clone', () => {
- let updater:Updater
- before(async() => {
- await rmrf(testFolder)
- })
-
- after(async() => {
- await rmrf(testFolder)
- })
-
- it('should have cloned a repo', (done) => {
- updater = new Updater({
- schema: 'https',
- localPath: testFolder,
- remoteHost: 'gitea.nitowa.xyz',
- remotePath: 'npm-packages',
- repoName: 'upgiter'
- })
- updater.getStatus().then( (status) => {
- const before = status
- updater.cloneRepo().then(() => {
- updater.getStatus().then( (status) => {
- if(status.exists && status.isRepo)
- done()
- else{
- console.log("before", before)
- console.log("after", status)
- done(new Error('Repo status was not set as expected'))
- }
- })
- })
- })
- })
- })
-
- describe('Tags / Versioning', () => {
- let updater:Updater
- beforeEach(async() => {
- await rmrf(testFolder)
- updater = new Updater({
- schema: 'https',
- localPath: testFolder,
- remoteHost: 'gitea.nitowa.xyz',
- remotePath: 'npm-packages',
- repoName: 'upgiter'
- })
- await updater.cloneRepo()
- })
-
- afterEach(async() => {
- await rmrf(testFolder)
- })
-
- it('should label versions correctly', (done) => {
- updater.getStatus().then( (status) => {
- if(status.currentTag === status.latestTag
- && status.latestTag === status.tags![status.tags!.length-1])
- done()
- else{
- console.log(status)
- done(new Error('Tags did not match expected values. Expected: '+status.latestTag+", but got: "+status.currentTag))
- }
- })
- })
-
- it('should check out versions', (done) => {
- updater.checkoutTag('1.0.7').then( (status) => {
- if(status.currentTag === '1.0.7')
- done()
- else{
- console.log(status)
- done(new Error('Did not check out 1.0.7. Was: '+status.currentTag))
- }
- })
- })
-
- it('should correctly check for outdate', (done) => {
- updater.isOutdated().then(outdated => {
- if(outdated) done(new Error("Expected repo to be up to date"))
- updater.checkoutTag('1.0.6').then( (status) => {
- updater.isOutdated().then(outdated => {
- if(outdated){
- done()
- }else{
- console.log(status)
- done(new Error('Did not become outdated'))
- }
- })
- })
- })
- })
- })
|