You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Test.ts 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { describe, it } from "mocha";
  2. import { Updater, rmrf } from '../Index'
  3. const testFolder = "CLONED_TEST_REPO"
  4. describe('Clone', () => {
  5. let updater:Updater
  6. before(async() => {
  7. await rmrf(testFolder)
  8. })
  9. after(async() => {
  10. await rmrf(testFolder)
  11. })
  12. it('should have cloned a repo', (done) => {
  13. updater = new Updater({
  14. schema: 'https',
  15. localPath: testFolder,
  16. remoteHost: 'gitea.nitowa.xyz',
  17. remotePath: 'npm-packages',
  18. repoName: 'upgiter'
  19. })
  20. updater.getStatus().then( (status) => {
  21. const before = status
  22. updater.cloneRepo().then(() => {
  23. updater.getStatus().then( (status) => {
  24. if(status.exists && status.isRepo)
  25. done()
  26. else{
  27. console.log("before", before)
  28. console.log("after", status)
  29. done(new Error('Repo status was not set as expected'))
  30. }
  31. })
  32. })
  33. })
  34. })
  35. })
  36. describe('Tags / Versioning', () => {
  37. let updater:Updater
  38. beforeEach(async() => {
  39. await rmrf(testFolder)
  40. updater = new Updater({
  41. schema: 'https',
  42. localPath: testFolder,
  43. remoteHost: 'gitea.nitowa.xyz',
  44. remotePath: 'npm-packages',
  45. repoName: 'upgiter'
  46. })
  47. await updater.cloneRepo()
  48. })
  49. afterEach(async() => {
  50. await rmrf(testFolder)
  51. })
  52. it('should label versions correctly', (done) => {
  53. updater.getStatus().then( (status) => {
  54. if(status.currentTag === status.latestTag
  55. && status.latestTag === status.tags![status.tags!.length-1])
  56. done()
  57. else{
  58. console.log(status)
  59. done(new Error('Tags did not match expected values. Expected: '+status.latestTag+", but got: "+status.currentTag))
  60. }
  61. })
  62. })
  63. it('should check out versions', (done) => {
  64. updater.checkoutTag('1.0.7').then( (status) => {
  65. if(status.currentTag === '1.0.7')
  66. done()
  67. else{
  68. console.log(status)
  69. done(new Error('Did not check out 1.0.7. Was: '+status.currentTag))
  70. }
  71. })
  72. })
  73. it('should correctly check for outdate', (done) => {
  74. updater.isOutdated().then(outdated => {
  75. if(outdated) done(new Error("Expected repo to be up to date"))
  76. updater.checkoutTag('1.0.6').then( (status) => {
  77. updater.isOutdated().then(outdated => {
  78. if(outdated){
  79. done()
  80. }else{
  81. console.log(status)
  82. done(new Error('Did not become outdated'))
  83. }
  84. })
  85. })
  86. })
  87. })
  88. })