Skip to content
Snippets Groups Projects
Unverified Commit ab3dc4e6 authored by Oleg Krivtsov's avatar Oleg Krivtsov Committed by GitHub
Browse files

test(manager/gradle-wrapper): fix snapshot regression in gradle-wrapper (#13144)

parent 395cab23
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ Array [ ...@@ -27,7 +27,7 @@ Array [
exports[`manager/gradle-wrapper/artifacts replaces existing value 1`] = ` exports[`manager/gradle-wrapper/artifacts replaces existing value 1`] = `
Array [ Array [
Object { Object {
"cmd": "<gradlew> wrapper --gradle-version 6.3", "cmd": "<gradlew> wrapper --gradle-distribution-url https://services.gradle.org/distributions/gradle-6.3-bin.zip",
"options": Object { "options": Object {
"cwd": "/root/project/lib/manager/gradle-wrapper/__fixtures__/testFiles", "cwd": "/root/project/lib/manager/gradle-wrapper/__fixtures__/testFiles",
"encoding": "utf-8", "encoding": "utf-8",
......
import { readFileSync } from 'fs-extra'; import { readFile, readFileSync } from 'fs-extra';
import Git from 'simple-git'; import Git from 'simple-git';
import { resolve } from 'upath'; import { resolve } from 'upath';
import * as httpMock from '../../../test/http-mock'; import * as httpMock from '../../../test/http-mock';
import { git, partial } from '../../../test/util'; import { git, partial } from '../../../test/util';
import { GlobalConfig } from '../../config/global'; import { GlobalConfig } from '../../config/global';
import type { RepoGlobalConfig } from '../../config/types'; import type { RepoGlobalConfig } from '../../config/types';
import { readLocalFile } from '../../util/fs';
import type { StatusResult } from '../../util/git/types'; import type { StatusResult } from '../../util/git/types';
import { ifSystemSupportsGradle } from '../gradle/deep/__testutil__/gradle'; import { ifSystemSupportsGradle } from '../gradle/deep/__testutil__/gradle';
import type { UpdateArtifactsConfig } from '../types'; import type { UpdateArtifactsConfig } from '../types';
...@@ -23,8 +22,8 @@ const config: UpdateArtifactsConfig = { ...@@ -23,8 +22,8 @@ const config: UpdateArtifactsConfig = {
newValue: '5.6.4', newValue: '5.6.4',
}; };
function readString(path: string): Promise<string> { function readString(...paths: string[]): Promise<string> {
return readLocalFile(path, 'utf8'); return readFile(resolve(fixtures, ...paths), 'utf8');
} }
function readBinSync(...paths: string[]): Buffer { function readBinSync(...paths: string[]): Buffer {
...@@ -65,7 +64,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => { ...@@ -65,7 +64,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => {
packageFileName: 'gradle/wrapper/gradle-wrapper.properties', packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
updatedDeps: [], updatedDeps: [],
newPackageFileContent: await readString( newPackageFileContent: await readString(
`../expectedFiles/gradle/wrapper/gradle-wrapper.properties` `./expectedFiles/gradle/wrapper/gradle-wrapper.properties`
), ),
config: { ...config, newValue: '6.3' }, config: { ...config, newValue: '6.3' },
}); });
...@@ -123,7 +122,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => { ...@@ -123,7 +122,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => {
packageFileName: 'gradle/wrapper/gradle-wrapper.properties', packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
updatedDeps: [], updatedDeps: [],
newPackageFileContent: await readString( newPackageFileContent: await readString(
`../testFiles/gradle/wrapper/gradle-wrapper.properties` `./testFiles/gradle/wrapper/gradle-wrapper.properties`
), ),
config, config,
}); });
...@@ -147,7 +146,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => { ...@@ -147,7 +146,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => {
packageFileName: 'gradle/wrapper/gradle-wrapper.properties', packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
updatedDeps: [], updatedDeps: [],
newPackageFileContent: await readString( newPackageFileContent: await readString(
`../testFiles/gradle/wrapper/gradle-wrapper.properties` `./testFiles/gradle/wrapper/gradle-wrapper.properties`
), ),
config, config,
}); });
...@@ -174,7 +173,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => { ...@@ -174,7 +173,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => {
packageFileName: 'gradle/wrapper/gradle-wrapper.properties', packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
updatedDeps: [], updatedDeps: [],
newPackageFileContent: await readString( newPackageFileContent: await readString(
`../testFiles/gradle/wrapper/gradle-wrapper.properties` `./testFiles/gradle/wrapper/gradle-wrapper.properties`
), ),
config, config,
}); });
...@@ -218,7 +217,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => { ...@@ -218,7 +217,7 @@ describe('manager/gradle-wrapper/artifacts-real', () => {
}) })
); );
const newContent = await readString(`../gradle-wrapper-sum.properties`); const newContent = await readString(`./gradle-wrapper-sum.properties`);
const result = await gradleWrapper.updateArtifacts({ const result = await gradleWrapper.updateArtifacts({
packageFileName: 'gradle/wrapper/gradle-wrapper.properties', packageFileName: 'gradle/wrapper/gradle-wrapper.properties',
...@@ -238,7 +237,10 @@ describe('manager/gradle-wrapper/artifacts-real', () => { ...@@ -238,7 +237,10 @@ describe('manager/gradle-wrapper/artifacts-real', () => {
expect(result[0].artifactError).toBeUndefined(); expect(result[0].artifactError).toBeUndefined();
expect( expect(
await readString(`gradle/wrapper/gradle-wrapper.properties`) await readString(
adminConfig.localDir,
`gradle/wrapper/gradle-wrapper.properties`
)
).toEqual(newContent); ).toEqual(newContent);
expect(httpMock.getTrace()).toEqual([ expect(httpMock.getTrace()).toEqual([
......
import { stat } from 'fs-extra'; import { readFile, stat } from 'fs-extra';
import { resolve } from 'upath'; import { resolve } from 'upath';
import { envMock, exec, mockExecAll } from '../../../test/exec-util'; import { envMock, exec, mockExecAll } from '../../../test/exec-util';
import * as httpMock from '../../../test/http-mock'; import * as httpMock from '../../../test/http-mock';
...@@ -37,7 +37,7 @@ addReplacingSerializer('gradlew.bat', '<gradlew>'); ...@@ -37,7 +37,7 @@ addReplacingSerializer('gradlew.bat', '<gradlew>');
addReplacingSerializer('./gradlew', '<gradlew>'); addReplacingSerializer('./gradlew', '<gradlew>');
function readString(...paths: string[]): Promise<string> { function readString(...paths: string[]): Promise<string> {
return fs.readLocalFile(resolve(fixtures, ...paths), 'utf8'); return readFile(resolve(fixtures, ...paths), 'utf8');
} }
describe('manager/gradle-wrapper/artifacts', () => { describe('manager/gradle-wrapper/artifacts', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment