diff --git a/cmd/rove/Dockerfile b/cmd/rove/Dockerfile deleted file mode 100644 index a5ae0d3..0000000 --- a/cmd/rove/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM golang:latest -LABEL maintainer="Marc Di Luzio " - -WORKDIR /app -COPY . . -RUN go mod download - -RUN go build -o rove -ldflags="-X 'github.com/mdiluz/rove/pkg/version.Version=$(git describe --always --long --dirty --tags)'" cmd/rove/main.go - -CMD [ "./rove" ] - diff --git a/cmd/rove/main_test.go b/cmd/rove/main_test.go index 405d1a8..52bf964 100644 --- a/cmd/rove/main_test.go +++ b/cmd/rove/main_test.go @@ -1,5 +1,3 @@ -// +build integration - package main import ( @@ -9,9 +7,22 @@ import ( "testing" "github.com/google/uuid" + "github.com/mdiluz/rove/pkg/server" "github.com/stretchr/testify/assert" ) +func TestMain(m *testing.M) { + s := server.NewServer(server.OptionPort(8080)) + s.Initialise() + go s.Run() + + code := m.Run() + + s.Close() + + os.Exit(code) +} + func Test_InnerMain(t *testing.T) { // Set up the flags to act locally and use a temporary file flag.Set("data", path.Join(os.TempDir(), uuid.New().String())) @@ -20,7 +31,7 @@ func Test_InnerMain(t *testing.T) { assert.Error(t, InnerMain("status")) // Now set the host - flag.Set("host", "localhost:80") + flag.Set("host", "localhost:8080") // No error now as we have a host assert.NoError(t, InnerMain("status")) diff --git a/docker-compose-test.yml b/docker-compose-test.yml deleted file mode 100644 index 5270e4f..0000000 --- a/docker-compose-test.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3' - -services: - rove-server: - build: - context: . - dockerfile: cmd/rove-server/Dockerfile - image: rove-server:latest - ports: - - "80:80" - command: ./rove-server --port 80 diff --git a/pkg/server/api_test.go b/pkg/server/api_test.go index ae41451..2ff3a89 100644 --- a/pkg/server/api_test.go +++ b/pkg/server/api_test.go @@ -1,4 +1,4 @@ -package integration +package server import ( "os" @@ -6,14 +6,13 @@ import ( "github.com/google/uuid" "github.com/mdiluz/rove/pkg/rove" - "github.com/mdiluz/rove/pkg/server" "github.com/stretchr/testify/assert" ) var serv rove.Server = "localhost:8080" func TestMain(m *testing.M) { - s := server.NewServer(server.OptionPort(8080)) + s := NewServer(OptionPort(8080)) s.Initialise() go s.Run() diff --git a/script/test.sh b/script/test.sh index 405b5f4..5b0ff09 100755 --- a/script/test.sh +++ b/script/test.sh @@ -4,18 +4,16 @@ cd "$(dirname "$0")" cd .. set -x -# Check that the cmdline client builds -docker build -f "cmd/rove/Dockerfile" . - -# Build and start rove-server -docker-compose -f docker-compose-test.yml up --detach --build - -# Run tests, including integration tests +# Check we can build everything go mod download -go test -v ./... -tags integration -cover -coverprofile=/tmp/c.out +go build ./... -# Take down the service +# Run the server and shut it down again to ensure our docker-compose works +docker-compose up --detach --build docker-compose down +# Run tests with coverage +go test -v ./... -cover -coverprofile=/tmp/c.out + # Convert the coverage data to html go tool cover -html=/tmp/c.out -o /tmp/coverage.html \ No newline at end of file