Преглед на файлове

Test that pyodide package.json version matches fetch script

GitOrigin-RevId: e04ae191d2b1e5a08ba2e27518e61899d0e2d490
Domagoj Kriskovic преди 5 месеца
родител
ревизия
11d35bd065
променени са 1 файла, в които са добавени 32 реда и са изтрити 0 реда
  1. 32 0
      services/web/test/unit/src/Scripts/FetchPyodidePackages.test.mjs

+ 32 - 0
services/web/test/unit/src/Scripts/FetchPyodidePackages.test.mjs

@@ -0,0 +1,32 @@
+import { readFile } from 'node:fs/promises'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const SERVICE_WEB_DIR = path.resolve(
+  path.dirname(fileURLToPath(import.meta.url)),
+  '../../../..'
+)
+
+describe('fetch-pyodide-packages.mjs', function () {
+  it('PYODIDE_VERSION matches the pyodide dependency in package.json', async function () {
+    const packageJson = JSON.parse(
+      await readFile(path.join(SERVICE_WEB_DIR, 'package.json'), 'utf8')
+    )
+    const scriptSource = await readFile(
+      path.join(SERVICE_WEB_DIR, 'scripts/fetch-pyodide-packages.mjs'),
+      'utf8'
+    )
+
+    const match = scriptSource.match(/PYODIDE_VERSION\s*=\s*'([^']+)'/)
+    expect(match, 'PYODIDE_VERSION constant not found in fetch script').to.not
+      .be.null
+    const scriptVersion = match[1]
+    const packageVersion =
+      packageJson.dependencies?.pyodide ?? packageJson.devDependencies?.pyodide
+
+    expect(scriptVersion).to.equal(
+      packageVersion,
+      'PYODIDE_VERSION in scripts/fetch-pyodide-packages.mjs must match the pyodide version in package.json; bump both together.'
+    )
+  })
+})