mirror of
https://github.com/gradle/wrapper-validation-action
synced 2024-11-24 01:22:01 +00:00
33646cf935
Always display all known and unknown found wrapper jars alongside their checksum. The display string building was pushed down from the Github Action main function, so it's easier to reuse and test it. Signed-off-by: Paul Merlin <paul@gradle.com>
64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
import * as path from 'path'
|
|
import * as validate from '../src/validate'
|
|
|
|
const baseDir = path.resolve('.')
|
|
|
|
test('succeeds if all found wrapper jars are valid', async () => {
|
|
const result = await validate.findInvalidWrapperJars(baseDir, 2, false, [
|
|
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
|
])
|
|
|
|
expect(result.isValid()).toBe(true)
|
|
|
|
expect(result.toDisplayString()).toBe(
|
|
'✓ Found known Gradle Wrapper JAR files\n' +
|
|
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' +
|
|
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar'
|
|
)
|
|
})
|
|
|
|
test('fails if invalid wrapper jars are found', async () => {
|
|
const result = await validate.findInvalidWrapperJars(baseDir, 2, false, [])
|
|
|
|
expect(result.isValid()).toBe(false)
|
|
|
|
expect(result.valid).toEqual([
|
|
new validate.WrapperJar(
|
|
'__tests__/data/valid/gradle-wrapper.jar',
|
|
'3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce'
|
|
)
|
|
])
|
|
|
|
expect(result.invalid).toEqual([
|
|
new validate.WrapperJar(
|
|
'__tests__/data/invalid/gradle-wrapper.jar',
|
|
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
|
)
|
|
])
|
|
|
|
expect(result.toDisplayString()).toBe(
|
|
'✗ Found unknown Gradle Wrapper JAR files\n' +
|
|
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' +
|
|
'✓ Found known Gradle Wrapper JAR files\n' +
|
|
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar'
|
|
)
|
|
})
|
|
|
|
test('fails if not enough wrapper jars are found', async () => {
|
|
const result = await validate.findInvalidWrapperJars(baseDir, 3, false, [])
|
|
|
|
expect(result.isValid()).toBe(false)
|
|
|
|
expect(result.errors).toEqual([
|
|
'Expected to find at least 3 Gradle Wrapper JARs but got only 2'
|
|
])
|
|
|
|
expect(result.toDisplayString()).toBe(
|
|
'✗ Found unknown Gradle Wrapper JAR files\n' +
|
|
' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 __tests__/data/invalid/gradle-wrapper.jar\n' +
|
|
'✗ Other validation errors\n' +
|
|
' Expected to find at least 3 Gradle Wrapper JARs but got only 2\n' +
|
|
'✓ Found known Gradle Wrapper JAR files\n' +
|
|
' 3888c76faa032ea8394b8a54e04ce2227ab1f4be64f65d450f8509fe112d38ce __tests__/data/valid/gradle-wrapper.jar'
|
|
)
|
|
})
|