Skip to content

Commit

Permalink
upgrade integration_test
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato authored and imjasonh committed Mar 26, 2024
1 parent 54752c6 commit a0cfc60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
32 changes: 17 additions & 15 deletions integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ echo "Copying ko to temp gopath."
mkdir -p "$GOPATH/src/github.com/google/ko"
cp -r "$ROOT_DIR/"* "$GOPATH/src/github.com/google/ko/"

pushd "$GOPATH/src/github.com/google/ko" || exit 1

echo "Building ko"

RESULT="$(GO111MODULE="on" GOFLAGS="-mod=vendor" go build .)"
Expand All @@ -31,51 +33,51 @@ FILTER="[^ ]local[^ ]*"
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 %)"
if [[ "$RESULT" != *"Hello World"* ]]; then
RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko/ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"Hello there"* ]]; then
echo "Test FAILED. Saw $RESULT" && exit 1
else
echo "Test PASSED"
fi

popd || exit 1

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

RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"TEST"* ]]; then
RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"Hello there"* ]]; then
echo "Test FAILED. Saw $RESULT" && exit 1
else
echo "Test PASSED"
fi

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 "3. Auto inside the module without vendoring should output Hello there"
RESULT="$(GO111MODULE=auto GOFLAGS="" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"Hello there"* ]]; then
echo "Test FAILED. Saw $RESULT" && exit 1
else
echo "Test PASSED"
fi

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 "4. On inside the module with vendor should output Hello there."
RESULT="$(GO111MODULE=on GOFLAGS="-mod=vendor" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"Hello there"* ]]; then
echo "Test FAILED. Saw $RESULT" && exit 1
else
echo "Test PASSED"
fi

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 "5. On inside the module without vendor should output Hello there"
RESULT="$(GO111MODULE=on GOFLAGS="" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"Hello there"* ]]; then
echo "Test FAILED. Saw $RESULT" && exit 1
else
echo "Test PASSED"
fi

echo "6. On outside the module should fail."
pushd .. || exit 1
GO111MODULE=on ./ko/ko build --local github.com/go-training/helloworld && exit 1
GO111MODULE=on ./ko/ko build --local "$GOPATH/src/github.com/google/ko/test" && exit 1
popd || exit 1

echo "7. On outside with build config specifying the test module builds."
Expand Down
4 changes: 2 additions & 2 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

var (
f = flag.String("f", "kenobi", "File in kodata to print")
wait = flag.Bool("wait", true, "Whether to wait for SIGTERM")
wait = flag.Bool("wait", false, "Whether to wait for SIGTERM")
)

// This is defined so we can test build-time variable setting using ldflags.
Expand Down Expand Up @@ -66,7 +66,7 @@ func main() {
if err != nil {
log.Fatalf("Error reading %q: %v", file, err)
}
log.Print(string(bytes))
fmt.Println(string(bytes))

// Cause the pod to "hang" to allow us to check for a readiness state.
if *wait {
Expand Down

0 comments on commit a0cfc60

Please sign in to comment.