mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix cache-key test on release branches
getCacheKey only hashes package contents when the version ends in -main; published releases short-circuit to the version string. The test asserted only the main-build property, so it failed on every release branch. Assert the correct property for each case.
This commit is contained in:
1 parent
6069149f25
commit
ad7b17d8ee
1 file changed
+16
-5
@@ -22,8 +22,19 @@ function getCacheKey(packageContents) {
|
||||
return require('../index').getCacheKey();
|
||||
}
|
||||
|
||||
test('cache key includes package metadata for main builds', () => {
|
||||
expect(getCacheKey('{"dependency":"1.0.0"}')).not.toBe(
|
||||
getCacheKey('{"dependency":"2.0.0"}'),
|
||||
);
|
||||
});
|
||||
const {version: packageVersion} = require('../../package.json');
|
||||
|
||||
// Only `-main` versions hash package contents; published releases short-circuit
|
||||
// to the version string, so each build asserts a different property.
|
||||
if (packageVersion.endsWith('-main')) {
|
||||
test('cache key includes package metadata for main builds', () => {
|
||||
expect(getCacheKey('{"dependency":"1.0.0"}')).not.toBe(
|
||||
getCacheKey('{"dependency":"2.0.0"}'),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
test('cache key is the package version for published releases', () => {
|
||||
expect(getCacheKey('{"dependency":"1.0.0"}')).toBe(packageVersion);
|
||||
expect(getCacheKey('{"dependency":"2.0.0"}')).toBe(packageVersion);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user