Signed-off-by: Paul Merlin <paul@gradle.com>
This commit is contained in:
Paul Merlin 2020-01-13 10:29:20 +01:00
parent a8266c0a0b
commit 6c65025c7d
3 changed files with 12 additions and 12 deletions

View file

@ -11,7 +11,7 @@ test('succeeds if all found wrapper jars are valid', async () => {
expect(result.isValid()).toBe(true) expect(result.isValid()).toBe(true)
expect(result.toDisplayString()).toBe( expect(result.toDisplayString()).toBe(
'✓ Found known Gradle Wrapper JAR files\n' + '✓ Found known Gradle Wrapper JAR files:\n' +
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' + ' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' +
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar' ' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar'
) )
@ -37,9 +37,9 @@ test('fails if invalid wrapper jars are found', async () => {
]) ])
expect(result.toDisplayString()).toBe( expect(result.toDisplayString()).toBe(
'✗ Found unknown Gradle Wrapper JAR files\n' + '✗ Found unknown Gradle Wrapper JAR files:\n' +
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' + ' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' +
'✓ Found known Gradle Wrapper JAR files\n' + '✓ Found known Gradle Wrapper JAR files:\n' +
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar' ' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar'
) )
}) })
@ -54,11 +54,11 @@ test('fails if not enough wrapper jars are found', async () => {
]) ])
expect(result.toDisplayString()).toBe( expect(result.toDisplayString()).toBe(
'✗ Found unknown Gradle Wrapper JAR files\n' + '✗ Found unknown Gradle Wrapper JAR files:\n' +
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' + ' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' +
'✗ Other validation errors\n' + '✗ Other validation errors:\n' +
' Expected to find at least 3 Gradle Wrapper JARs but got only 2\n' + ' Expected to find at least 3 Gradle Wrapper JARs but got only 2\n' +
'✓ Found known Gradle Wrapper JAR files\n' + '✓ Found known Gradle Wrapper JAR files:\n' +
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar' ' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar'
) )
}) })

6
dist/index.js vendored
View file

@ -980,17 +980,17 @@ class ValidationResult {
toDisplayString() { toDisplayString() {
let displayString = ''; let displayString = '';
if (this.invalid.length > 0) { if (this.invalid.length > 0) {
displayString += `✗ Found unknown Gradle Wrapper JAR files\n${ValidationResult.toDisplayList(this.invalid)}`; displayString += `✗ Found unknown Gradle Wrapper JAR files:\n${ValidationResult.toDisplayList(this.invalid)}`;
} }
if (this.errors.length > 0) { if (this.errors.length > 0) {
if (displayString.length > 0) if (displayString.length > 0)
displayString += '\n'; displayString += '\n';
displayString += `✗ Other validation errors\n ${this.errors.join(`\n `)}`; displayString += `✗ Other validation errors:\n ${this.errors.join(`\n `)}`;
} }
if (this.valid.length > 0) { if (this.valid.length > 0) {
if (displayString.length > 0) if (displayString.length > 0)
displayString += '\n'; displayString += '\n';
displayString += `✓ Found known Gradle Wrapper JAR files\n${ValidationResult.toDisplayList(this.valid)}`; displayString += `✓ Found known Gradle Wrapper JAR files:\n${ValidationResult.toDisplayList(this.valid)}`;
} }
return displayString; return displayString;
} }

View file

@ -47,19 +47,19 @@ export class ValidationResult {
toDisplayString(): string { toDisplayString(): string {
let displayString = '' let displayString = ''
if (this.invalid.length > 0) { if (this.invalid.length > 0) {
displayString += `✗ Found unknown Gradle Wrapper JAR files\n${ValidationResult.toDisplayList( displayString += `✗ Found unknown Gradle Wrapper JAR files:\n${ValidationResult.toDisplayList(
this.invalid this.invalid
)}` )}`
} }
if (this.errors.length > 0) { if (this.errors.length > 0) {
if (displayString.length > 0) displayString += '\n' if (displayString.length > 0) displayString += '\n'
displayString += `✗ Other validation errors\n ${this.errors.join( displayString += `✗ Other validation errors:\n ${this.errors.join(
`\n ` `\n `
)}` )}`
} }
if (this.valid.length > 0) { if (this.valid.length > 0) {
if (displayString.length > 0) displayString += '\n' if (displayString.length > 0) displayString += '\n'
displayString += `✓ Found known Gradle Wrapper JAR files\n${ValidationResult.toDisplayList( displayString += `✓ Found known Gradle Wrapper JAR files:\n${ValidationResult.toDisplayList(
this.valid this.valid
)}` )}`
} }