forked from ko-build/ko
-
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.
Add integration tests for various go mod corner cases. (ko-build#179)
* Add manual integration tests for various go mod corner cases. * Move integration test back and actually test the outputs. I realize now this is run in a travis CI job :) So I'll make it actually work. * Add _, gofmt * Add tools build constraint. * Stop redirecting stderr * Use local mode to support CI.
- Loading branch information
Jon Donovan
authored
Aug 5, 2020
1 parent
ab4ca8e
commit 6e4a93e
Showing
10 changed files
with
207 additions
and
1 deletion.
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
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,7 @@ | ||
// +build tools | ||
|
||
package hack | ||
|
||
import ( | ||
_ "github.com/go-training/helloworld" | ||
) |
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 |
---|---|---|
@@ -1,2 +1,103 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
ROOT_DIR=$(dirname $0) | ||
|
||
pushd "$ROOT_DIR" | ||
|
||
ROOT_DIR="$(pwd)" | ||
|
||
echo "Running smoke test." | ||
go install ./cmd/ko | ||
ko apply -f ./cmd/ko/test -L | ||
ko apply -f ./cmd/ko/test -L | ||
|
||
echo "Moving GOPATH into /tmp/ to test modules behavior." | ||
export ORIGINAL_GOPATH="$GOPATH" | ||
export GOPATH="$(mktemp -d)" | ||
|
||
pushd "$GOPATH" || exit 1 | ||
|
||
echo "Copying ko to temp gopath." | ||
mkdir -p "$GOPATH/src/github.com/google/ko" | ||
cp -r "$ROOT_DIR/"* "$GOPATH/src/github.com/google/ko/" | ||
|
||
echo "Downloading github.com/go-training/helloworld" | ||
go get -d github.com/go-training/helloworld | ||
|
||
pushd "$GOPATH/src/github.com/google/ko" || exit 1 | ||
|
||
echo "Replacing hello world in vendor with TEST." | ||
sed -i 's/Hello World/TEST/g' ./vendor/github.com/go-training/helloworld/main.go | ||
|
||
echo "Building ko" | ||
|
||
RESULT="$(GO111MODULE="on" GOFLAGS="-mod=vendor" go build ./cmd/ko)" | ||
|
||
echo "Beginning scenarios." | ||
|
||
FILTER="[^ ]local[^ ]*" | ||
|
||
echo "1. GOPATH mode should always create an image that outputs 'Hello World'" | ||
RESULT="$(GO111MODULE=off ./ko publish --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" | ||
if [[ "$RESULT" != *"Hello World"** ]]; then | ||
echo "Test FAILED. Saw $RESULT" && exit 1 | ||
else | ||
echo "Test PASSED" | ||
fi | ||
|
||
echo "2. Go module auto mode should create an image that outputs 'Hello World' when run outside the module." | ||
|
||
pushd .. || exit 1 | ||
RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko/ko publish --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" | ||
if [[ "$RESULT" != *"Hello World"* ]]; then | ||
echo "Test FAILED. Saw $RESULT" && exit 1 | ||
else | ||
echo "Test PASSED" | ||
fi | ||
|
||
popd || exit 1 | ||
|
||
echo "3. Auto inside the module with vendoring should output TEST" | ||
|
||
RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko publish --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" | ||
if [[ "$RESULT" != *"TEST"* ]]; then | ||
echo "Test FAILED. Saw $RESULT" && exit 1 | ||
else | ||
echo "Test PASSED" | ||
fi | ||
|
||
echo "4. Auto inside the module without vendoring should output Hello World" | ||
RESULT="$(GO111MODULE=auto GOFLAGS="" ./ko publish --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" | ||
if [[ "$RESULT" != *"Hello World"* ]]; then | ||
echo "Test FAILED. Saw $RESULT" && exit 1 | ||
else | ||
echo "Test PASSED" | ||
fi | ||
|
||
echo "5. On inside the module with vendor should output TEST." | ||
RESULT="$(GO111MODULE=on GOFLAGS="-mod=vendor" ./ko publish --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" | ||
if [[ "$RESULT" != *"TEST"* ]]; then | ||
echo "Test FAILED. Saw $RESULT" && exit 1 | ||
else | ||
echo "Test PASSED" | ||
fi | ||
|
||
echo "6. On inside the module without vendor should output Hello World" | ||
RESULT="$(GO111MODULE=on GOFLAGS="" ./ko publish --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" | ||
if [[ "$RESULT" != *"Hello World"* ]]; then | ||
echo "Test FAILED. Saw $RESULT" && exit 1 | ||
else | ||
echo "Test PASSED" | ||
fi | ||
|
||
echo "7. On outside the module should fail." | ||
pushd .. || exit 1 | ||
GO111MODULE=on ./ko/ko publish --local github.com/go-training/helloworld && exit 1 | ||
|
||
popd || exit 1 | ||
popd || exit 1 | ||
popd || exit 1 | ||
|
||
export GOPATH="$ORIGINAL_GOPATH" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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