-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea430e6
commit 2694a90
Showing
4 changed files
with
112 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
createBuilder | ||
docker buildx build -o type=registry --build-arg build-arg --platform=target1,target2 args -t docker-registry/docker-repo:tag1 -t docker-registry/docker-repo:tag2 -t docker-registry/docker-repo:mocked-git-branch --cache-from=type=registry,ref=docker-registry/docker-repo:mocked-git-branch --cache-from=type=registry,ref=docker-registry/docker-repo:mocked-git-branch -f dockerfile build-context-dir 2>&1 | ||
removeBuilder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
createBuilder | ||
docker buildx build -o type=registry --build-arg build-arg --platform=target1,target2 args -t docker-registry/docker-repo:tag1 -t docker-registry/docker-repo:tag2 -t docker-registry/docker-repo:mocked-git-branch --cache-from=type=registry,ref=docker-registry/docker-repo:mocked-git-branch --cache-from=type=registry,ref=docker-registry/docker-repo:mocked-git-branch -f dockerfile build-context-dir 2>&1 | ||
removeBuilder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
OUTPUT_FILE="$SCRIPT_DIR/output" | ||
|
||
source ../../src/dockerBuild.sh | ||
|
||
# Set up mocks | ||
function getGitVersion | ||
{ | ||
echo "mocked-git-version" | ||
} | ||
export -f getGitVersion | ||
|
||
function getGitBranch | ||
{ | ||
echo "mocked-git-branch" | ||
} | ||
export -f getGitBranch | ||
|
||
function createBuilder | ||
{ | ||
echo "createBuilder" >> "$OUTPUT_FILE" | ||
} | ||
export -f createBuilder | ||
|
||
function removeBuilder | ||
{ | ||
echo "removeBuilder" >> "$OUTPUT_FILE" | ||
} | ||
export -f removeBuilder | ||
|
||
function build | ||
{ | ||
echo "$1" >> "$OUTPUT_FILE" | ||
} | ||
export -f build | ||
|
||
|
||
function oneTimeSetUp() | ||
{ | ||
echo "oneTimeSetUp" | ||
} | ||
|
||
function oneTimeTearDown() | ||
{ | ||
echo "oneTimeTearDown" | ||
rm "$OUTPUT_FILE" | ||
} | ||
|
||
testAllArgs() | ||
{ | ||
local REGISTRY=docker-registry | ||
local REPO=docker-repo | ||
local BUILD_CONTEXT=build-context-dir | ||
local DOCKERFILE=dockerfile | ||
local GIT_DIR=git-dir | ||
local TAGS=tag1,tag2 | ||
local BUILD_ARG=build-arg | ||
local PLATFORM=target1,target2 | ||
local ARGS=args | ||
|
||
result=$(dockerBuild -e $REGISTRY -r $REPO -d $BUILD_CONTEXT -f $DOCKERFILE -g $GIT_DIR -t $TAGS -b $BUILD_ARG -p $PLATFORM -a $ARGS) | ||
echo "$result" | ||
output=$(<"$OUTPUT_FILE") | ||
expected=$(<"$SCRIPT_DIR/expected/allArgs") | ||
assertEquals "$expected" "$output" | ||
} | ||
|
||
# Load and run shUnit2. | ||
. shunit2 |