diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6f8a2f8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tests/test_helper/bats-support"] + path = tests/test_helper/bats-support + url = https://github.com/ztombol/bats-support +[submodule "tests/test_helper/bats-assert"] + path = tests/test_helper/bats-assert + url = https://github.com/ztombol/bats-assert diff --git a/tests/install-plugins/Dockerfile b/tests/install-plugins/Dockerfile index 72d28f7..ad1db16 100644 --- a/tests/install-plugins/Dockerfile +++ b/tests/install-plugins/Dockerfile @@ -1,3 +1,3 @@ FROM bats-jenkins -RUN /usr/local/bin/install-plugins.sh maven-plugin@2.7.1 +RUN /usr/local/bin/install-plugins.sh maven-plugin:2.7.1 diff --git a/tests/test_helper/bats-assert b/tests/test_helper/bats-assert new file mode 160000 index 0000000..9f88b42 --- /dev/null +++ b/tests/test_helper/bats-assert @@ -0,0 +1 @@ +Subproject commit 9f88b4207da750093baabc4e3f41bf68f0dd3630 diff --git a/tests/test_helper/bats-support b/tests/test_helper/bats-support new file mode 160000 index 0000000..d0a1318 --- /dev/null +++ b/tests/test_helper/bats-support @@ -0,0 +1 @@ +Subproject commit d0a131831c487a1f1141e76d3ab386c89642cdff diff --git a/tests/tests.bats b/tests/tests.bats index 01f42fe..65ecf74 100644 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -3,6 +3,8 @@ SUT_IMAGE=bats-jenkins SUT_CONTAINER=bats-jenkins +load 'test_helper/bats-support/load' +load 'test_helper/bats-assert/load' load test_helpers @test "build image" { @@ -49,9 +51,24 @@ load test_helpers bash -c "curl -fsSL --user \"admin:$(get_jenkins_password)\" $(get_jenkins_url)/systemInfo | sed 's/<\/tr>/<\/tr>\'$'\n/g' | grep 'user.timezone' | sed -e '${sed_expr}'" } -@test "plugins are installed" { +@test "plugins are installed with plugins.sh" { docker build -t $SUT_IMAGE-plugins $BATS_TEST_DIRNAME/plugins - assert "maven-plugin.jpi maven-plugin.jpi.pinned" docker run -ti --rm $SUT_IMAGE-plugins ls /var/jenkins_home/plugins | sed -e 's/ / /' + assert_success + # replace DOS line endings \r\n + run bash -c "docker run -ti --rm $SUT_IMAGE-plugins ls -1 /var/jenkins_home/plugins | tr -d '\r'" + assert_success + assert_line 'maven-plugin.jpi' + assert_line 'maven-plugin.jpi.pinned' +} + +@test "plugins are installed with install-plugins.sh" { + run docker build -t $SUT_IMAGE-install-plugins $BATS_TEST_DIRNAME/install-plugins + assert_success + # replace DOS line endings \r\n + run bash -c "docker run -ti --rm $SUT_IMAGE-plugins ls -1 /var/jenkins_home/plugins | tr -d '\r'" + assert_success + assert_line 'maven-plugin.jpi' + assert_line 'maven-plugin.jpi.pinned' } @test "clean test containers" {