Skip to content

Commit

Permalink
Update integration_test.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored Mar 26, 2024
1 parent 76e4023 commit cb4cf9b
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ 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"
GO111MODULE=off 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 .)"
Expand All @@ -36,15 +28,7 @@ echo "Beginning scenarios."

FILTER="[^ ]local[^ ]*"

echo "1. GOPATH mode should always create an image that outputs 'Hello World'"
RESULT="$(GO111MODULE=off ./ko build --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."
echo "1. 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 build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)"
Expand All @@ -56,7 +40,7 @@ fi

popd || exit 1

echo "3. Auto inside the module with vendoring should output TEST"
echo "2. Auto inside the module with vendoring should output TEST"

RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"TEST"* ]]; then
Expand All @@ -65,36 +49,36 @@ else
echo "Test PASSED"
fi

echo "4. Auto inside the module without vendoring should output TEST"
echo "3. Auto inside the module without vendoring should output TEST"
RESULT="$(GO111MODULE=auto GOFLAGS="" ./ko build --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 "5. On inside the module with vendor should output TEST."
echo "4. On inside the module with vendor should output TEST."
RESULT="$(GO111MODULE=on GOFLAGS="-mod=vendor" ./ko build --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 TEST"
echo "5. On inside the module without vendor should output TEST"
RESULT="$(GO111MODULE=on GOFLAGS="" ./ko build --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 "7. On outside the module should fail."
echo "6. On outside the module should fail."
pushd .. || exit 1
GO111MODULE=on ./ko/ko build --local github.com/go-training/helloworld && exit 1
popd || exit 1

echo "8. On outside with build config specifying the test module builds."
echo "7. On outside with build config specifying the test module builds."
pushd test/build-configs || exit 1
for app in foo bar ; do
# test both local and fully qualified import paths
Expand Down

0 comments on commit cb4cf9b

Please sign in to comment.