diff --git a/core/test/version_test.ts b/core/test/version_test.ts index 2a49e02af..9e867dd09 100644 --- a/core/test/version_test.ts +++ b/core/test/version_test.ts @@ -8,11 +8,20 @@ import {version} from '@google/adk'; import {readFileSync} from 'node:fs'; import {describe, expect, it} from 'vitest'; +/** major.minor.patch, with an optional pre-release suffix. */ +const SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/; + describe('version', () => { it('matches the version declared in package.json', () => { - const pkg: {version: string} = JSON.parse( + const pkg: {name: string; version: string} = JSON.parse( readFileSync(new URL('../package.json', import.meta.url), 'utf-8'), ); + + // release-please holds every workspace at the same version, so a read that + // resolved to the wrong manifest would still compare equal. Pin the name. + expect(pkg.name).toBe('@google/adk'); + // Guards against both sides being undefined, which would compare equal. + expect(version).toMatch(SEMVER_PATTERN); expect(version).toBe(pkg.version); }); }); diff --git a/dev/test/version_test.ts b/dev/test/version_test.ts index 5c01eef1a..79fa1f4d5 100644 --- a/dev/test/version_test.ts +++ b/dev/test/version_test.ts @@ -9,11 +9,20 @@ import {describe, expect, it} from 'vitest'; import {version} from '../src/version.js'; +/** major.minor.patch, with an optional pre-release suffix. */ +const SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/; + describe('version', () => { it('matches the version declared in package.json', () => { - const pkg: {version: string} = JSON.parse( + const pkg: {name: string; version: string} = JSON.parse( readFileSync(new URL('../package.json', import.meta.url), 'utf-8'), ); + + // release-please holds every workspace at the same version, so a read that + // resolved to the wrong manifest would still compare equal. Pin the name. + expect(pkg.name).toBe('@google/adk-devtools'); + // Guards against both sides being undefined, which would compare equal. + expect(version).toMatch(SEMVER_PATTERN); expect(version).toBe(pkg.version); }); });