diff --git a/acceptance-tests.Dockerfile b/acceptance-tests.Dockerfile index 6fb0773..18a1c41 100644 --- a/acceptance-tests.Dockerfile +++ b/acceptance-tests.Dockerfile @@ -44,4 +44,8 @@ COPY --from=git-team /go/bin/git-team /usr/local/bin/git-team WORKDIR / +ENV USERNAME git-team-acceptance-test +RUN adduser -D ${USERNAME} +USER ${USERNAME} + ENTRYPOINT ["bash", "/usr/local/bin/bats"] diff --git a/acceptance-tests/disable_global.bats b/acceptance-tests/disable_global.bats index eb644ed..61fe03f 100644 --- a/acceptance-tests/disable_global.bats +++ b/acceptance-tests/disable_global.bats @@ -10,7 +10,7 @@ setup() { } teardown() { - rm /root/.gitconfig + rm /home/git-team-acceptance-test/.gitconfig } @test "git-team: (scope: global) disable should disable a previously enabled git-team" { @@ -67,9 +67,9 @@ teardown() { /usr/local/bin/git-team enable 'A ' 'B ' /usr/local/bin/git-team disable - run bash -c "ls -la /root/.git-team/commit-templates/global/COMMIT_TEMPLATE" + run bash -c "ls -la /home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE" assert_failure 1 - assert_line "ls: /root/.git-team/commit-templates/global/COMMIT_TEMPLATE: No such file or directory" + assert_line "ls: /home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE: No such file or directory" } @test "git-team: (scope: global) disable should treat a previously disabled git-team idempotently" { diff --git a/acceptance-tests/disable_repo_local.bats b/acceptance-tests/disable_repo_local.bats index 415c70d..5ba084c 100644 --- a/acceptance-tests/disable_repo_local.bats +++ b/acceptance-tests/disable_repo_local.bats @@ -26,7 +26,7 @@ teardown() { cd - rm -rf $REPO_PATH - rm /root/.gitconfig + rm /home/git-team-acceptance-test/.gitconfig } @test "git-team: (scope: repo-local) disable should disable a previously enabled git-team" { @@ -80,9 +80,9 @@ teardown() { /usr/local/bin/git-team enable 'A ' 'B ' /usr/local/bin/git-team disable - run bash -c "ls -la /root/.git-team/commit-templates/repo-local/$REPO_CHECKSUM" + run bash -c "ls -la /home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM" assert_failure 1 - assert_line "ls: /root/.git-team/commit-templates/repo-local/$REPO_CHECKSUM: No such file or directory" + assert_line "ls: /home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM: No such file or directory" } @test "git-team: (scope: repo-local) disable should treat a previously disabled git-team idempotently" { diff --git a/acceptance-tests/enable_global.bats b/acceptance-tests/enable_global.bats index 9e8445c..80e353d 100644 --- a/acceptance-tests/enable_global.bats +++ b/acceptance-tests/enable_global.bats @@ -39,7 +39,7 @@ teardown() { } @test "git-team: (scope: global) enable should not set the git-team hooks path as the previous hooks path" { - git config --global core.hooksPath "/root/.git-team/hooks" + git config --global core.hooksPath "/home/git-team-acceptance-test/.git-team/hooks" /usr/local/bin/git-team b a c 'Ad-hoc ' @@ -73,17 +73,17 @@ teardown() { @test "git-team: (scope: global) enable should enable the prepare-commit-msg hook" { run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && git config --global core.hooksPath" assert_success - assert_line '/root/.git-team/hooks' + assert_line '/home/git-team-acceptance-test/.git-team/hooks' } @test "git-team: (scope: global) enable should set a commit template" { run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && git config --global commit.template" assert_success - assert_line '/root/.git-team/commit-templates/global/COMMIT_TEMPLATE' + assert_line '/home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE' } @test "git-team: (scope: global) enable should provision the commit template" { - run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && cat /root/.git-team/commit-templates/global/COMMIT_TEMPLATE" + run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && cat /home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE" assert_success assert_line --index 0 'Co-authored-by: A ' assert_line --index 1 'Co-authored-by: Ad-hoc ' @@ -92,7 +92,7 @@ teardown() { } @test "git-team: (scope: global) enable 'all via -A' should provision the commit template" { - run bash -c "/usr/local/bin/git-team enable -A &>/dev/null && cat /root/.git-team/commit-templates/global/COMMIT_TEMPLATE" + run bash -c "/usr/local/bin/git-team enable -A &>/dev/null && cat /home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE" assert_success assert_line --index 0 'Co-authored-by: A ' assert_line --index 1 'Co-authored-by: B ' @@ -100,7 +100,7 @@ teardown() { } @test "git-team: (scope: global) enable 'all via --all' should provision the commit template" { - run bash -c "/usr/local/bin/git-team enable --all &>/dev/null && cat /root/.git-team/commit-templates/global/COMMIT_TEMPLATE" + run bash -c "/usr/local/bin/git-team enable --all &>/dev/null && cat /home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE" assert_success assert_line --index 0 'Co-authored-by: A ' assert_line --index 1 'Co-authored-by: B ' diff --git a/acceptance-tests/enable_repo_local.bats b/acceptance-tests/enable_repo_local.bats index 9caa0ef..be0929b 100644 --- a/acceptance-tests/enable_repo_local.bats +++ b/acceptance-tests/enable_repo_local.bats @@ -54,7 +54,7 @@ teardown() { } @test "git-team: (scope: repo-local) enable should not set the git-team hooks path as the previous hooks path" { - git config --local core.hooksPath "/root/.git-team/hooks" + git config --local core.hooksPath "/home/git-team-acceptance-test/.git-team/hooks" /usr/local/bin/git-team b a c 'Ad-hoc ' @@ -86,17 +86,17 @@ teardown() { @test "git-team: (scope: repo-local) enable should set the prepare-commit-msg hook" { run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && git config --local core.hooksPath" assert_success - assert_line '/root/.git-team/hooks' + assert_line '/home/git-team-acceptance-test/.git-team/hooks' } @test "git-team: (scope: repo-local) enable should set the commit template" { run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && git config --local commit.template" assert_success - assert_line "/root/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" + assert_line "/home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" } @test "git-team: (scope: repo-local) enable should provision the commit template" { - run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && cat /root/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" + run bash -c "/usr/local/bin/git-team b a c 'Ad-hoc ' &>/dev/null && cat /home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" assert_success assert_line --index 0 'Co-authored-by: A ' assert_line --index 1 'Co-authored-by: Ad-hoc ' @@ -105,7 +105,7 @@ teardown() { } @test "git-team: (scope: repo-local) enable 'all via -A' should provision the commit template" { - run bash -c "/usr/local/bin/git-team enable -A &>/dev/null && cat /root/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" + run bash -c "/usr/local/bin/git-team enable -A &>/dev/null && cat /home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" assert_success assert_line --index 0 'Co-authored-by: A ' assert_line --index 1 'Co-authored-by: B ' @@ -113,7 +113,7 @@ teardown() { } @test "git-team: (scope: repo-local) enable 'all via --all' should provision the commit template" { - run bash -c "/usr/local/bin/git-team enable --all &>/dev/null && cat /root/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" + run bash -c "/usr/local/bin/git-team enable --all &>/dev/null && cat /home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM/COMMIT_TEMPLATE" assert_success assert_line --index 0 'Co-authored-by: A ' assert_line --index 1 'Co-authored-by: B ' diff --git a/acceptance-tests/use_cases_disabled.bats b/acceptance-tests/use_cases_disabled.bats index 6e86260..6b83788 100644 --- a/acceptance-tests/use_cases_disabled.bats +++ b/acceptance-tests/use_cases_disabled.bats @@ -26,7 +26,7 @@ teardown() { cd - rm -rf $REPO_PATH - rm /root/.gitconfig + rm /home/git-team-acceptance-test/.gitconfig } @test "use case: when git-team is disabled, a merge commit should not have co-authors injected" { diff --git a/acceptance-tests/use_cases_global.bats b/acceptance-tests/use_cases_global.bats index 177bf29..94c16b6 100644 --- a/acceptance-tests/use_cases_global.bats +++ b/acceptance-tests/use_cases_global.bats @@ -27,7 +27,7 @@ teardown() { cd - rm -rf $REPO_PATH - rm /root/.gitconfig + rm /home/git-team-acceptance-test/.gitconfig } @test "use case: (scope: global) an existing repo-local git hook should be respected - commit-msg" { diff --git a/acceptance-tests/use_cases_repo_local.bats b/acceptance-tests/use_cases_repo_local.bats index 90c4b34..c4afd7f 100644 --- a/acceptance-tests/use_cases_repo_local.bats +++ b/acceptance-tests/use_cases_repo_local.bats @@ -27,7 +27,7 @@ teardown() { cd - rm -rf $REPO_PATH - rm /root/.gitconfig + rm /home/git-team-acceptance-test/.gitconfig } @test "use case: (scope: repo-local) an existing repo-local git hook should be respected - commit msg" {