11package org .scalasteward .core .vcs
22
3+ import cats .syntax .all ._
34import munit .CatsEffectSuite
45import org .http4s .HttpApp
56import org .http4s .dsl .Http4sDsl
67import org .http4s .implicits ._
78import org .scalasteward .core .application .Config .VCSCfg
9+ import org .scalasteward .core .coursier .DependencyMetadata
810import org .scalasteward .core .data .ReleaseRelatedUrl .{CustomReleaseNotes , VersionDiff }
911import org .scalasteward .core .data .Version
1012import org .scalasteward .core .mock .MockContext .context ._
@@ -23,42 +25,44 @@ class VCSExtraAlgTest extends CatsEffectSuite with Http4sDsl[MockEff] {
2325 private val v2 = Version (" 0.2.0" )
2426
2527 test(" getReleaseRelatedUrls: repoUrl not found" ) {
26- val obtained =
27- vcsExtraAlg.getReleaseRelatedUrls(uri " https://github.com/foo/foo " , None , v1, v2).runA(state)
28+ val metadata = DependencyMetadata .empty.copy(scmUrl = uri " https://github.com/foo/foo " .some)
29+ val obtained = vcsExtraAlg.getReleaseRelatedUrls(metadata , v1, v2).runA(state)
2830 assertIO(obtained, List .empty)
2931 }
3032
3133 test(" getReleaseRelatedUrls: repoUrl ok" ) {
32- val obtained =
33- vcsExtraAlg.getReleaseRelatedUrls(uri " https://github.com/foo/bar " , None , v1, v2).runA(state)
34+ val metadata = DependencyMetadata .empty.copy(scmUrl = uri " https://github.com/foo/bar " .some)
35+ val obtained = vcsExtraAlg.getReleaseRelatedUrls(metadata , v1, v2).runA(state)
3436 val expected = List (VersionDiff (uri " https://github.com/foo/bar/compare/v0.1.0...v0.2.0 " ))
3537 assertIO(obtained, expected)
3638 }
3739
3840 test(" getReleaseRelatedUrls: repoUrl and releaseNotesUrl ok" ) {
39- val releaseNotesUrl = uri " https://github.com/foo/bar/README.md#changelog "
40- val obtained = vcsExtraAlg
41- .getReleaseRelatedUrls(uri " https://github.com/foo/bar " , Some (releaseNotesUrl), v1, v2)
42- .runA(state)
41+ val metadata = DependencyMetadata .empty.copy(
42+ scmUrl = uri " https://github.com/foo/bar " .some,
43+ releaseNotesUrl = uri " https://github.com/foo/bar/README.md#changelog " .some
44+ )
45+ val obtained = vcsExtraAlg.getReleaseRelatedUrls(metadata, v1, v2).runA(state)
4346 val expected = List (
44- CustomReleaseNotes (releaseNotesUrl),
47+ CustomReleaseNotes (metadata. releaseNotesUrl.get ),
4548 VersionDiff (uri " https://github.com/foo/bar/compare/v0.1.0...v0.2.0 " )
4649 )
4750 assertIO(obtained, expected)
4851 }
4952
5053 test(" getReleaseRelatedUrls: releaseNotesUrl is in possibleReleaseRelatedUrls" ) {
51- val releaseNotesUrl = uri " https://github.com/foo/bar1/blob/master/RELEASES.md "
52- val obtained = vcsExtraAlg
53- .getReleaseRelatedUrls(uri " https://github.com/foo/bar1 " , Some (releaseNotesUrl), v1, v2)
54- .runA(state)
55- val expected = List (CustomReleaseNotes (releaseNotesUrl))
54+ val metadata = DependencyMetadata .empty.copy(
55+ scmUrl = uri " https://github.com/foo/bar1 " .some,
56+ releaseNotesUrl = uri " https://github.com/foo/bar1/blob/master/RELEASES.md " .some
57+ )
58+ val obtained = vcsExtraAlg.getReleaseRelatedUrls(metadata, v1, v2).runA(state)
59+ val expected = List (CustomReleaseNotes (metadata.releaseNotesUrl.get))
5660 assertIO(obtained, expected)
5761 }
5862
5963 test(" getReleaseRelatedUrls: repoUrl permanent redirect" ) {
60- val obtained =
61- vcsExtraAlg.getReleaseRelatedUrls(uri " https://github.com/foo/buz " , None , v1, v2).runA(state)
64+ val metadata = DependencyMetadata .empty.copy(scmUrl = uri " https://github.com/foo/buz " .some)
65+ val obtained = vcsExtraAlg.getReleaseRelatedUrls(metadata , v1, v2).runA(state)
6266 assertIO(obtained, List .empty)
6367 }
6468
@@ -72,25 +76,25 @@ class VCSExtraAlgTest extends CatsEffectSuite with Http4sDsl[MockEff] {
7276 private val githubOnPremVcsExtraAlg = VCSExtraAlg .create[MockEff ](config)
7377
7478 test(" getReleaseRelatedUrls: on-prem, repoUrl not found" ) {
75- val obtained = githubOnPremVcsExtraAlg
76- .getReleaseRelatedUrls( uri " https://github.on-prem.com/foo/foo " , None , v1, v2 )
77- .runA(state)
79+ val metadata =
80+ DependencyMetadata .empty.copy(scmUrl = uri " https://github.on-prem.com/foo/foo " .some )
81+ val obtained = githubOnPremVcsExtraAlg.getReleaseRelatedUrls(metadata, v1, v2) .runA(state)
7882 assertIO(obtained, List .empty)
7983 }
8084
8185 test(" getReleaseRelatedUrls: on-prem, repoUrl ok" ) {
82- val obtained = githubOnPremVcsExtraAlg
83- .getReleaseRelatedUrls( uri " https://github.on-prem.com/foo/bar " , None , v1, v2 )
84- .runA(state)
86+ val metadata =
87+ DependencyMetadata .empty.copy(scmUrl = uri " https://github.on-prem.com/foo/bar " .some )
88+ val obtained = githubOnPremVcsExtraAlg.getReleaseRelatedUrls(metadata, v1, v2) .runA(state)
8589 val expected =
8690 List (VersionDiff (uri " https://github.on-prem.com/foo/bar/compare/v0.1.0...v0.2.0 " ))
8791 assertIO(obtained, expected)
8892 }
8993
9094 test(" getReleaseRelatedUrls: on-prem, repoUrl permanent redirect" ) {
91- val obtained = githubOnPremVcsExtraAlg
92- .getReleaseRelatedUrls( uri " https://github.on-prem.com/foo/buz " , None , v1, v2 )
93- .runA(state)
95+ val metadata =
96+ DependencyMetadata .empty.copy(scmUrl = uri " https://github.on-prem.com/foo/buz " .some )
97+ val obtained = githubOnPremVcsExtraAlg.getReleaseRelatedUrls(metadata, v1, v2) .runA(state)
9498 assertIO(obtained, List .empty)
9599 }
96100}
0 commit comments