Commit 3b3dc2b0 authored by Joel Jans's avatar Joel Jans

First commit

parent 1a912d87
Pipeline #270 passed with stages
in 2 minutes and 35 seconds
image: docker:19.03.8
variables:
DOCKER_TLS_CERTDIR: "/certs"
BASE_DOMAIN: "171.22.246.208.xip.io"
services:
- docker:19.03.8-dind
stages:
- test
- build
integration_tests:
image: golang:1.13-alpine
tags:
- riigipilv
stage: test
script:
- export CGO_ENABLED=0
- go test -v ./...
build_docker:
tags:
- riigipilv
stage: build
script:
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker build -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:latest
FROM golang:1.13-alpine
WORKDIR /app
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
GOPROXY=https://proxy.golang.org
COPY ./go.mod .
RUN go mod download
COPY . .
# it will take the flags from the environment
RUN go build -a -v -ldflags '-s -w' -o app.bin
CMD ["/app/app.bin"]
package main
import "github.com/gin-gonic/gin"
func setupRouter() *gin.Engine {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.String(200, "hello world")
})
r.GET("/healthz", func(c *gin.Context) {
c.String(200, "healthy")
})
return r
}
func main() {
r := setupRouter()
r.Run()
}
package main
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRoute(t *testing.T) {
router := setupRouter()
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/", nil)
router.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
assert.Equal(t, "hello world", w.Body.String())
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment