mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
e5f2f1414e
Improve integration tests
83 lines
2.4 KiB
Go
83 lines
2.4 KiB
Go
//go:build integration
|
|
// +build integration
|
|
|
|
// can be executed with
|
|
// go test -v -tags integration -run TestMavenIntegration ./integration/...
|
|
|
|
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestMavenIntegrationBuildCloudSdkSpringProject(t *testing.T) {
|
|
t.Parallel()
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
Image: "maven:3-openjdk-8-slim",
|
|
User: "1000",
|
|
TestDir: []string{"testdata", "TestMavenIntegration", "cloud-sdk-spring-archetype"},
|
|
Mounts: map[string]string{},
|
|
Setup: []string{},
|
|
})
|
|
defer container.terminate(t)
|
|
|
|
err := container.whenRunningPiperCommand("mavenBuild", "")
|
|
if err != nil {
|
|
t.Fatalf("Calling piper command failed %s", err)
|
|
}
|
|
|
|
container.assertHasOutput(t, "BUILD SUCCESS")
|
|
container.assertHasFiles(t,
|
|
"/project/application/target/cloud-sdk-spring-archetype-application.jar",
|
|
"/tmp/.m2/repository",
|
|
)
|
|
|
|
err = container.whenRunningPiperCommand("mavenExecuteIntegration", "")
|
|
if err != nil {
|
|
t.Fatalf("Calling piper command failed %s", err)
|
|
}
|
|
|
|
container.assertHasOutput(t,
|
|
"INFO mydemo.HelloWorldControllerTest - Starting HelloWorldControllerTest",
|
|
"Tests run: 1, Failures: 0, Errors: 0, Skipped: 0",
|
|
)
|
|
|
|
container.assertHasFiles(t, "/project/integration-tests/target/coverage-reports/jacoco.exec")
|
|
}
|
|
|
|
func TestMavenIntegrationBuildCloudSdkTomeeProject(t *testing.T) {
|
|
t.Parallel()
|
|
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
|
Image: "maven:3-openjdk-8-slim",
|
|
User: "1000",
|
|
TestDir: []string{"testdata", "TestMavenIntegration", "cloud-sdk-tomee-archetype"},
|
|
Mounts: map[string]string{},
|
|
Setup: []string{},
|
|
})
|
|
defer container.terminate(t)
|
|
|
|
err := container.whenRunningPiperCommand("mavenBuild", "")
|
|
if err != nil {
|
|
t.Fatalf("Calling piper command failed %s", err)
|
|
}
|
|
|
|
container.assertHasOutput(t, "BUILD SUCCESS")
|
|
container.assertHasFiles(t,
|
|
"/project/application/target/cloud-sdk-tomee-archetype-application-classes.jar",
|
|
"/project/application/target/cloud-sdk-tomee-archetype-application.war",
|
|
"/tmp/.m2/repository",
|
|
)
|
|
|
|
err = container.whenRunningPiperCommand("mavenExecuteIntegration", "")
|
|
if err != nil {
|
|
t.Fatalf("Calling piper command failed %s", err)
|
|
}
|
|
|
|
container.assertHasOutput(t,
|
|
"(prepare-agent) @ cloud-sdk-tomee-archetype-integration-tests",
|
|
"Tests run: 1, Failures: 0, Errors: 0, Skipped: 0",
|
|
)
|
|
|
|
container.assertHasFiles(t, "/project/integration-tests/target/coverage-reports/jacoco.exec")
|
|
}
|