diff --git a/vgo/src/test/kotlin/com/jzbrooks/vgo/CommandLineInterfaceTests.kt b/vgo-cli/src/test/kotlin/com/jzbrooks/vgo/cli/CommandLineInterfaceTests.kt similarity index 99% rename from vgo/src/test/kotlin/com/jzbrooks/vgo/CommandLineInterfaceTests.kt rename to vgo-cli/src/test/kotlin/com/jzbrooks/vgo/cli/CommandLineInterfaceTests.kt index dd7f6365..84a3382b 100644 --- a/vgo/src/test/kotlin/com/jzbrooks/vgo/CommandLineInterfaceTests.kt +++ b/vgo-cli/src/test/kotlin/com/jzbrooks/vgo/cli/CommandLineInterfaceTests.kt @@ -1,4 +1,4 @@ -package com.jzbrooks.vgo +package com.jzbrooks.vgo.cli import assertk.assertThat import assertk.assertions.contains @@ -6,6 +6,7 @@ import assertk.assertions.doesNotContain import assertk.assertions.isEqualTo import assertk.assertions.matches import assertk.assertions.startsWith +import com.jzbrooks.vgo.Vgo import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeEach diff --git a/vgo/src/test/kotlin/com/jzbrooks/vgo/BaselineTests.kt b/vgo/src/test/kotlin/com/jzbrooks/vgo/BaselineTests.kt index c34dab54..b2002763 100644 --- a/vgo/src/test/kotlin/com/jzbrooks/vgo/BaselineTests.kt +++ b/vgo/src/test/kotlin/com/jzbrooks/vgo/BaselineTests.kt @@ -20,9 +20,15 @@ class BaselineTests { val inputFile = unoptimizedAsset.toFile() val inputFileName = inputFile.name.substring(0, inputFile.name.lastIndexOf('.')) val outputFilePath = "build/test-results/${inputFileName}_testOptimizationFinishes.${inputFile.extension}" - val arguments = arrayOf(unoptimizedAsset.toString(), "-o", outputFilePath, "--indent", "2") - val exitCode = Vgo().run(arguments) + val options = + Vgo.Options( + indent = 2, + input = listOf(unoptimizedAsset.toString()), + output = listOf(outputFilePath), + ) + + val exitCode = Vgo(options).run() assertThat(exitCode).isEqualTo(0) } @@ -36,9 +42,14 @@ class BaselineTests { val inputFile = unoptimizedAsset.toFile() val inputFileName = inputFile.name.substring(0, inputFile.name.lastIndexOf('.')) val outputFilePath = "build/test-results/${inputFileName}_testOptimizedAssetIsEquivalentToBaseline.${inputFile.extension}" - val arguments = arrayOf(unoptimizedAsset.toString(), "-o", outputFilePath, "--indent", "2") + val options = + Vgo.Options( + indent = 2, + input = listOf(unoptimizedAsset.toString()), + output = listOf(outputFilePath), + ) - Vgo().run(arguments) + Vgo(options).run() val content = File(outputFilePath) val baselineContent = baselineAsset.toFile() @@ -54,9 +65,14 @@ class BaselineTests { val inputFile = unoptimizedAsset.toFile() val inputFileName = inputFile.name.substring(0, inputFile.name.lastIndexOf('.')) val outputFilePath = "build/test-results/${inputFileName}_testOptimizedAssetIsNotLargerThanBaseline.${inputFile.extension}" - val arguments = arrayOf(unoptimizedAsset.toString(), "-o", outputFilePath, "--indent", "2") + val options = + Vgo.Options( + indent = 2, + input = listOf(unoptimizedAsset.toString()), + output = listOf(outputFilePath), + ) - Vgo().run(arguments) + Vgo(options).run() val optimizedAssetSize = File(outputFilePath).length() val baselineAssetSize = baselineAsset.toFile().length() @@ -70,9 +86,14 @@ class BaselineTests { val inputFile = unoptimizedAsset.toFile() val inputFileName = inputFile.name.substring(0, inputFile.name.lastIndexOf('.')) val outputFilePath = "build/test-results/${inputFileName}_testOptimizedAssetIsNotLargerThanOriginal.${inputFile.extension}" - val arguments = arrayOf(unoptimizedAsset.toString(), "-o", outputFilePath, "--indent", "2") - - Vgo().run(arguments) + val options = + Vgo.Options( + indent = 2, + input = listOf(unoptimizedAsset.toString()), + output = listOf(outputFilePath), + ) + + Vgo(options).run() val optimizedAssetSize = File(outputFilePath).length() val unoptimizedAssetSize = unoptimizedAsset.toFile().length() diff --git a/vgo/src/test/kotlin/com/jzbrooks/vgo/InPlaceModificationTest.kt b/vgo/src/test/kotlin/com/jzbrooks/vgo/InPlaceModificationTest.kt index ad0647b6..a502a06c 100644 --- a/vgo/src/test/kotlin/com/jzbrooks/vgo/InPlaceModificationTest.kt +++ b/vgo/src/test/kotlin/com/jzbrooks/vgo/InPlaceModificationTest.kt @@ -42,18 +42,23 @@ class InPlaceModificationTest { @Test fun `in-place optimization completes successfully`() { - val arguments = arrayOf("src/test/resources/in-place-modify") - - val exitCode = Vgo().run(arguments) + val options = + Vgo.Options( + input = listOf("src/test/resources/in-place-modify"), + ) + val exitCode = Vgo(options).run() assertThat(exitCode).isEqualTo(0) } @Test fun `individual file statistics are reported with a directory input`() { - val arguments = arrayOf("src/test/resources/in-place-modify", "--stats") - - Vgo().run(arguments) + val options = + Vgo.Options( + printStats = true, + input = listOf("src/test/resources/in-place-modify"), + ) + Vgo(options).run() assertThat(systemOutput.toString()) .contains(Paths.get("src/test/resources/in-place-modify/avocado_example.xml").toString()) @@ -61,9 +66,13 @@ class InPlaceModificationTest { @Test fun `non-vector files are not mentioned in statistics reporting with a directory input`() { - val arguments = arrayOf("src/test/resources/in-place-modify", "--stats") + val options = + Vgo.Options( + printStats = true, + input = listOf("src/test/resources/in-place-modify"), + ) - Vgo().run(arguments) + Vgo(options).run() assertThat(systemOutput.toString()) .doesNotContain("src/test/resources/in-place-modify/non_vector.xml") @@ -71,9 +80,13 @@ class InPlaceModificationTest { @Test fun `only modified files appear in statistics reporting`() { - val arguments = arrayOf("src/test/resources/in-place-modify", "--stats") + val options = + Vgo.Options( + printStats = true, + input = listOf("src/test/resources/in-place-modify"), + ) - Vgo().run(arguments) + Vgo(options).run() assertThat(systemOutput.toString()) .doesNotContain("src/test/resources/in-place-modify/avocado_example_optimized.xml") @@ -84,7 +97,11 @@ class InPlaceModificationTest { val input = File("src/test/resources/in-place-modify/non_vector.xml") val before = input.readText() - Vgo().run(arrayOf(input.parent)) + val options = + Vgo.Options( + input = listOf(input.parent.toString()), + ) + Vgo(options).run() val after = input.readText() assertThat(after).isEqualTo(before)