]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add more tests for plugin rebuild
authorChocobozzz <me@florianbigard.com>
Wed, 3 Aug 2022 13:16:56 +0000 (15:16 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 3 Aug 2022 13:16:56 +0000 (15:16 +0200)
server/models/application/application.ts
server/tests/api/server/plugins.ts

index d4590e0019fae76df4b6bcae06f76dae85c68ba7..c51ceb2454b3990344c6d7c163400abc83fa3ceb 100644 (file)
@@ -73,5 +73,7 @@ export class ApplicationModel extends Model<Partial<AttributesOnly<ApplicationMo
 
     application.nodeABIVersion = getNodeABIVersion()
     application.nodeVersion = process.version
+
+    await application.save()
   }
 }
index 3ae99dc2ec182341b783e2da840145a685caa44c..15c0937582f682c9c2fb19e84c4213ba1db6f55f 100644 (file)
@@ -353,6 +353,13 @@ describe('Test plugins', function () {
   })
 
   it('Should rebuild native modules on Node ABI change', async function () {
+    this.timeout(50000)
+
+    const removeNativeModule = async () => {
+      await remove(join(baseNativeModule, 'build'))
+      await remove(join(baseNativeModule, 'prebuilds'))
+    }
+
     await command.install({ path: PluginsCommand.getPluginTestPath('-native') })
 
     await makeGetRequest({
@@ -365,20 +372,33 @@ describe('Test plugins', function () {
     await server.sql.updateQuery(query)
 
     const baseNativeModule = server.servers.buildDirectory(join('plugins', 'node_modules', 'a-native-example'))
-    await remove(join(baseNativeModule, 'build'))
-    await remove(join(baseNativeModule, 'prebuilds'))
 
+    await removeNativeModule()
     await server.kill()
     await server.run()
 
-    await pathExists(join(baseNativeModule, 'build'))
-    await pathExists(join(baseNativeModule, 'prebuilds'))
+    expect(await pathExists(join(baseNativeModule, 'build'))).to.be.true
+    expect(await pathExists(join(baseNativeModule, 'prebuilds'))).to.be.true
 
     await makeGetRequest({
       url: server.url,
       path: '/plugins/test-native/router',
       expectedStatus: HttpStatusCode.NO_CONTENT_204
     })
+
+    await removeNativeModule()
+
+    await server.kill()
+    await server.run()
+
+    expect(await pathExists(join(baseNativeModule, 'build'))).to.be.false
+    expect(await pathExists(join(baseNativeModule, 'prebuilds'))).to.be.false
+
+    await makeGetRequest({
+      url: server.url,
+      path: '/plugins/test-native/router',
+      expectedStatus: HttpStatusCode.NOT_FOUND_404
+    })
   })
 
   after(async function () {