mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
Check booleans for falseness
This commit is contained in:
48
test.bats
48
test.bats
@@ -82,7 +82,7 @@ teardown() {
|
||||
|
||||
@test "with tag names it pushes tags using the name" {
|
||||
export GITHUB_REF='refs/tags/myRelease'
|
||||
export INPUT_TAG_NAMES=true
|
||||
export INPUT_TAG_NAMES="true"
|
||||
|
||||
run /entrypoint.sh
|
||||
|
||||
@@ -95,6 +95,21 @@ teardown() {
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "with tag names set to false it doesn't push tags using the name" {
|
||||
export GITHUB_REF='refs/tags/myRelease'
|
||||
export INPUT_TAG_NAMES="false"
|
||||
|
||||
run /entrypoint.sh
|
||||
|
||||
expectStdOut "
|
||||
::set-output name=tag::latest"
|
||||
|
||||
expectMockCalled "/usr/local/bin/docker login -u USERNAME --password-stdin
|
||||
/usr/local/bin/docker build -t my/repository:latest .
|
||||
/usr/local/bin/docker push my/repository:latest
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "it pushes specific Dockerfile to latest" {
|
||||
export INPUT_DOCKERFILE='MyDockerFileName'
|
||||
|
||||
@@ -132,6 +147,26 @@ teardown() {
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "it does not push a snapshot by sha and date in addition when turned off" {
|
||||
export INPUT_SNAPSHOT='false'
|
||||
export GITHUB_SHA='12169ed809255604e557a82617264e9c373faca7'
|
||||
|
||||
declare -A -p MOCK_RETURNS=(
|
||||
['/usr/local/bin/docker']=""
|
||||
['/usr/bin/date']="197001010101"
|
||||
) > mockReturns
|
||||
|
||||
run /entrypoint.sh
|
||||
|
||||
expectStdOut "
|
||||
::set-output name=tag::latest"
|
||||
|
||||
expectMockCalled "/usr/local/bin/docker login -u USERNAME --password-stdin
|
||||
/usr/local/bin/docker build -t my/repository:latest .
|
||||
/usr/local/bin/docker push my/repository:latest
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "it caches image from former build and uses it for snapshot" {
|
||||
export GITHUB_SHA='12169ed809255604e557a82617264e9c373faca7'
|
||||
export INPUT_SNAPSHOT='true'
|
||||
@@ -264,6 +299,17 @@ teardown() {
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "it does not cache the image from a former build if set to false" {
|
||||
export INPUT_CACHE='false'
|
||||
|
||||
run /entrypoint.sh
|
||||
|
||||
expectMockCalled "/usr/local/bin/docker login -u USERNAME --password-stdin
|
||||
/usr/local/bin/docker build -t my/repository:latest .
|
||||
/usr/local/bin/docker push my/repository:latest
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "it pushes pull requests when configured" {
|
||||
export GITHUB_REF='refs/pull/24/merge'
|
||||
export GITHUB_SHA='12169ed809255604e557a82617264e9c373faca7'
|
||||
|
||||
Reference in New Issue
Block a user