-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CONSUL-183] Create Bats Dockerfile (#8)
- Loading branch information
1 parent
a2e7802
commit 5587848
Showing
8 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
test/integration/connect/envoy/Dockerfile-bats-core-windows
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,15 @@ | ||
FROM mcr.microsoft.com/windows/servercore:1809 | ||
|
||
RUN ["powershell", "Set-ExecutionPolicy", "Bypass", "-Scope", "Process", "-Force;"] | ||
RUN ["powershell", "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"] | ||
|
||
RUN choco install git.install -yf | ||
|
||
ENV BATS_URL=https://github.com/bats-core/bats-core/archive/refs/tags/v1.7.0.zip | ||
RUN curl %BATS_URL% -L -o bats.zip | ||
|
||
RUN mkdir bats-core | ||
RUN tar -xf bats.zip -C bats-core --strip-components=1 | ||
RUN cd "C:\\Program Files\\Git\\bin" && bash.exe -c "/c/bats-core/install.sh /c/bats" | ||
|
||
ENTRYPOINT ["C:\\Program Files\\Git\\bin\\bash.exe", "C:\\bats\\bin\\bats"] |
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,9 @@ | ||
FROM docker.mirror.hashicorp.services/windows/fortio AS fortio | ||
|
||
FROM docker.mirror.hashicorp.services/windows/bats:1.7.0 | ||
|
||
RUN choco install openssl -yf | ||
RUN choco install jq -yf | ||
|
||
COPY --from=fortio C:\\fortio C:\\fortio | ||
ENV PATH C:\\fortio;%PATH% |
4 changes: 4 additions & 0 deletions
4
test/integration/connect/envoy/case-dummy-bats/dummy-function.bash
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,4 @@ | ||
function dummyFunction { | ||
local LOCAL_VAR=$1 | ||
echo $LOCAL_VAR $COMMON_VAR | ||
} |
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 @@ | ||
echo $1 >> $2 |
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,2 @@ | ||
COMMON_VAR="Common variable" | ||
TXT_FILE_NAME="file.txt" |
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,9 @@ | ||
@test "Basic Test 1" { | ||
result=4 | ||
[ "$result" -eq 4 ] | ||
} | ||
|
||
@test "Basic Test 2" { | ||
result=10 | ||
[ "$result" -eq 10 ] | ||
} |
30 changes: 30 additions & 0 deletions
30
test/integration/connect/envoy/case-dummy-bats/verify_2.bats
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,30 @@ | ||
#!/usr/bin/env bats | ||
|
||
load dummy-function | ||
|
||
setup() { | ||
source $(pwd)/workdir/vars.sh | ||
source $(pwd)/workdir/setup.sh "Content of the created setup.txt file in setup.sh" $TXT_FILE_NAME | ||
} | ||
|
||
teardown() { | ||
rm $TXT_FILE_NAME | ||
} | ||
|
||
@test "Test with dummyFunction invoked" { | ||
FIRST_ARG="First Argument" | ||
|
||
run dummyFunction "$FIRST_ARG" | ||
|
||
[ $status -eq 0 ] | ||
[ -n "$output" ] # Not empty | ||
[ "$output" = "$FIRST_ARG $COMMON_VAR" ] | ||
} | ||
|
||
@test "Test skipped" { | ||
skip | ||
|
||
run not_existing_function | ||
|
||
[ "$status" -eq 100000 ] | ||
} |
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