|
| 1 | +package org.scalasteward.core.repoconfig |
| 2 | + |
| 3 | +import munit.FunSuite |
| 4 | +import org.scalasteward.core.TestSyntax.* |
| 5 | + |
| 6 | +class PullRequestUpdateFilterTest extends FunSuite { |
| 7 | + |
| 8 | + object Update { |
| 9 | + val kinesisClient = |
| 10 | + ("software.amazon.kinesis".g % "amazon-kinesis-client".a % "3.0.2" %> "3.0.3").single |
| 11 | + val s3Client = ("software.amazon.awssdk".g % "s3".a % "2.31.60" %> "2.31.61").single |
| 12 | + val play = ("org.playframework".g % "sbt-plugin".a % "3.0.6" %> "3.0.7").single |
| 13 | + val contentApiClient = ("com.gu".g % "content-api-client".a % "34.1.1" %> "8.1.5").single |
| 14 | + val playGoogleAuth = ("com.gu.play-googleauth".g % "play-v30".a % "23.0.0" %> "24.0.0").single |
| 15 | + } |
| 16 | + |
| 17 | + test("Allow a wildcard group id") { |
| 18 | + val groupFilter = PullRequestUpdateFilter(group = Some("*")).toOption.get |
| 19 | + |
| 20 | + assert(groupFilter.matches(Update.kinesisClient)) |
| 21 | + assert(groupFilter.matches(Update.s3Client)) |
| 22 | + assert(groupFilter.matches(Update.play)) |
| 23 | + } |
| 24 | + |
| 25 | + test("Allow a wildcard-suffix on group id") { |
| 26 | + val groupFilter = PullRequestUpdateFilter(group = Some("software.amazon.*")).toOption.get |
| 27 | + |
| 28 | + assert(groupFilter.matches(Update.kinesisClient)) |
| 29 | + assert(groupFilter.matches(Update.s3Client)) |
| 30 | + |
| 31 | + assert(!groupFilter.matches(Update.play)) |
| 32 | + } |
| 33 | + |
| 34 | + test("Not match a non-wildcard group id if it is only partially specified") { |
| 35 | + val groupFilter = PullRequestUpdateFilter(group = Some("software.amazon")).toOption.get |
| 36 | + |
| 37 | + assert(!groupFilter.matches(Update.kinesisClient)) |
| 38 | + assert(!groupFilter.matches(Update.s3Client)) |
| 39 | + assert(!groupFilter.matches(Update.play)) |
| 40 | + } |
| 41 | + |
| 42 | + test("Not match a non-wildcard group id if it is only partially specified") { |
| 43 | + val groupFilter = PullRequestUpdateFilter(group = Some("com.gu.*")).toOption.get |
| 44 | + |
| 45 | + assert(groupFilter.matches(Update.contentApiClient)) |
| 46 | + assert(groupFilter.matches(Update.playGoogleAuth)) |
| 47 | + } |
| 48 | +} |
0 commit comments