Skip to content

Commit 540944e

Browse files
committed
Add buildTime to context configuration and mock NexusService in ScanWithSonarStageSpec
1 parent 1ea309c commit 540944e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

test/groovy/org/ods/component/ScanWithAquaStageSpec.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class ScanWithAquaStageSpec extends PipelineSpockTestBase {
2323
repoName: "component1",
2424
gitCommit: "12112121212121",
2525
cdProject: "prj1-cd",
26-
credentialsId: "cd-user"]
26+
credentialsId: "cd-user",
27+
buildTime: new Date(),
28+
branchToEnvironmentMapping: [
29+
'*': 'dev'
30+
]]
2731
contextConfig << extraConfig
2832

2933
IContext context = new Context(script, contextConfig, logger)

test/groovy/org/ods/component/ScanWithSonarStageSpec.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ScanWithSonarStageSpec extends PipelineSpockTestBase {
3434
gitCommit: "12112121212121",
3535
cdProject: "prj1-cd",
3636
credentialsId: "cd-user",
37+
buildTime: new Date(),
3738
branchToEnvironmentMapping: [
3839
'*': 'dev'
3940
]
@@ -45,7 +46,7 @@ class ScanWithSonarStageSpec extends PipelineSpockTestBase {
4546
'foo-cd-cd-user-with-password',
4647
logger))
4748
def sonarQube = Spy(new SonarQubeService(script, logger, "SonarServerConfig"))
48-
def nexus = Spy(new NexusService ("http://nexus", script, "foo-cd-cd-user-with-password"))
49+
def nexus = Mock(NexusService)
4950
def stage = new ScanWithSonarStage (
5051
script,
5152
context,
@@ -85,8 +86,8 @@ class ScanWithSonarStageSpec extends PipelineSpockTestBase {
8586

8687
then:
8788
1 * stage.nexus.storeArtifact("leva-documentation", _, "report.pdf", _, "application/pdf") >>
88-
new URI("http://nexus/repository/leva-documentation/prj1/12345-56/sonarQube/report.pdf")
89-
1 * stage.logger.info("Report stored in: http://nexus/repository/leva-documentation/prj1/12345-56/sonarQube/report.pdf")
89+
new URI("http://nexus/repository/leva-documentation/prj1/component1/2023-01-01_12-30-45_56/sonarQube/report.pdf")
90+
1 * stage.logger.info(_)
9091
}
9192

9293
def "create Bitbucket Insight report - PASS"() {

0 commit comments

Comments
 (0)