Skip to content

Commit

Permalink
Migrate tests and add tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek authored and Goooler committed Dec 9, 2024
1 parent fc52577 commit 80b9b77
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ yarn-error.log
src/docs/.vuepress/dist/
.DS_Store
jd-gui.cfg
lib/
bin/
.vscode/
.kotlin
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class SimpleRelocatorTest {
assertThat(relocator.canRelocatePath("org/R\$string.class")).isFalse()

// Exclude with Regex
relocator = SimpleRelocator("org.foo")
relocator.exclude("%regex[org/foo/.*Factory[0-9].*]")
relocator = SimpleRelocator("org.foo", excludes = listOf("%regex[org/foo/.*Factory[0-9].*]"))
assertThat(relocator.canRelocatePath("org/foo/Factory.class")).isTrue()
assertThat(relocator.canRelocatePath("org/foo/FooFactoryMain.class")).isTrue()
assertThat(relocator.canRelocatePath("org/foo/BarFactory.class")).isTrue()
Expand Down Expand Up @@ -221,6 +220,56 @@ class SimpleRelocatorTest {
assertThat(relocator.canRelocatePath("META-INF/maven/com-foo-bar/artifactId/pom.xml")).isTrue()
}

@Test
fun testCanRelocateExcludedSourceFile() {
val relocator = SimpleRelocator(
"org.foo",
excludes = listOf("org/apache/iceberg/spark/parquet/**", "org/apache/spark/sql/execution/datasources/parquet/**"),
)
assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet.class")).isFalse()
assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet\$.class")).isFalse()
assertThat(relocator.canRelocatePath("org/apache/spark/sql/execution/datasources/parquet/v1.class")).isFalse()
assertThat(relocator.canRelocatePath("org/foo/Class.class")).isTrue()
}

@Test
fun testCanRelocateExcludedSourceFileWithRegex() {
val relocator = SimpleRelocator(
"org.foo",
excludes = listOf("%regex[org/apache/iceberg/.*]", "%regex[org/apache/spark/.*]"),
)
assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet.class")).isFalse()
assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet\$.class")).isFalse()
assertThat(relocator.canRelocatePath("org/apache/spark/sql/execution/datasources/parquet/v1.class")).isFalse()
assertThat(relocator.canRelocatePath("org/foo/Class.class")).isTrue()
}

@Test
fun testCanRelocateIncludedSourceFile() {
val relocator = SimpleRelocator(
"org.foo",
includes = listOf("org/apache/iceberg/spark/parquet/**", "org/apache/spark/sql/execution/datasources/parquet/**"),
)

assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet.class")).isTrue()
assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet\$.class")).isTrue()
assertThat(relocator.canRelocatePath("org/apache/spark/sql/execution/datasources/parquet/v1.class")).isTrue()
assertThat(relocator.canRelocatePath("org/foo/Class.class")).isFalse()
}

@Test
fun testCanRelocateIncludedSourceFileWithRegex() {
val relocator = SimpleRelocator(
"org.foo",
includes = listOf("%regex[org/apache/iceberg/.*]", "%regex[org/apache/spark/.*]"),
)

assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet.class")).isTrue()
assertThat(relocator.canRelocatePath("org/apache/iceberg/spark/parquet/SparkNativeParquet\$.class")).isTrue()
assertThat(relocator.canRelocatePath("org/apache/spark/sql/execution/datasources/parquet/v1.class")).isTrue()
assertThat(relocator.canRelocatePath("org/foo/Class.class")).isFalse()
}

@Test
fun testRelocateSourceWithExcludesRaw() {
val relocator = SimpleRelocator(
Expand Down

0 comments on commit 80b9b77

Please sign in to comment.