De-integration the cmd/rove tests as well and massively simplify the tests output

This commit is contained in:
Marc Di Luzio 2020-06-06 00:47:48 +01:00
parent 79c07f359b
commit 3bfbe38837
5 changed files with 23 additions and 37 deletions

View file

@ -1,11 +0,0 @@
FROM golang:latest
LABEL maintainer="Marc Di Luzio <marc.diluzio@gmail.com>"
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" ]

View file

@ -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"))