From 09d3175c4869daaa74b8e7b6a2fdd6959dcbe969 Mon Sep 17 00:00:00 2001 From: Viktor Farcic Date: Sun, 6 Jan 2019 17:08:28 +0100 Subject: [PATCH 1/2] This is a PR --- main.go | 2 +- main_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 9fd166f02..a7278e1e1 100644 --- a/main.go +++ b/main.go @@ -92,7 +92,7 @@ func HelloServer(w http.ResponseWriter, req *http.Request) { delayNum, _ := strconv.Atoi(delay) sleep(time.Duration(delayNum) * time.Millisecond) } - io.WriteString(w, "hello, world!\n") + io.WriteString(w, "hello, PR!\n") } func RandomErrorServer(w http.ResponseWriter, req *http.Request) { diff --git a/main_test.go b/main_test.go index 06855af90..6ea073a0b 100644 --- a/main_test.go +++ b/main_test.go @@ -88,7 +88,7 @@ func (s *MainTestSuite) Test_HelloServer_WritesHelloWorld() { HelloServer(w, req) - w.AssertCalled(s.T(), "Write", []byte("hello, world!\n")) + w.AssertCalled(s.T(), "Write", []byte("hello, PR!\n")) } func (s *MainTestSuite) Test_HelloServer_Waits_WhenDelayIsPresent() { From 44c1b9db69ab1d2810620a26fc28e45b41ea1828 Mon Sep 17 00:00:00 2001 From: Viktor Farcic Date: Sun, 6 Jan 2019 17:17:56 +0100 Subject: [PATCH 2/2] Added unit tests --- Jenkinsfile | 1 + Makefile | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5dfe2b386..7b0d6ad26 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,7 @@ pipeline { container('go') { dir('/home/jenkins/go/src/github.com/vfarcic/go-demo-6') { checkout scm + sh "make unit-test" sh "make linux" sh "export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml" sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION" diff --git a/Makefile b/Makefile index 37b34fe23..597aa9d0a 100644 --- a/Makefile +++ b/Makefile @@ -60,3 +60,5 @@ lint: vendor | $(PKGS) $(GOLINT) # ❷ test -z "$$($(GOLINT) $$pkg | tee /dev/stderr)" || ret=1 ; \ done ; exit $$ret +unit-test: + CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v --run UnitTest --cover