From 97e24cc51382c12c317a728dc2c1fc81ebfb72bb Mon Sep 17 00:00:00 2001 From: Pierre Dubouilh Date: Sun, 4 Oct 2020 16:38:08 +0200 Subject: [PATCH] fixup tests --- Makefile | 28 ++++++++++++++++------------ src/gossa_test.go | 31 ++++++------------------------- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 02f9d05..765aebe 100755 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ build: cp src/gossa.go gossa.go make -C gossa-ui/ go vet && go fmt - CGO_ENABLED=0 go build gossa.go + CGO_ENABLED=0 go build rm gossa.go install: @@ -22,7 +22,16 @@ test: -rm gossa_test.go -@cd test-fixture && ln -s ../support . cp src/gossa_test.go . - go test + -@killall gossa + make run & + go test -run TestNormal + killall gossa + make run-extra & + go test -run TestExtra + killall gossa + make run-ro & + go test -run TestRo + killall gossa watch: ls src/* gossa-ui/* | entr -rc make build run @@ -39,16 +48,11 @@ watch-test: build-all: cp src/gossa.go gossa.go make -C gossa-ui/ - env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build gossa.go - mv gossa gossa-linux64 - env GOOS=linux GOARCH=arm go build gossa.go - mv gossa gossa-linux-arm - env GOOS=linux GOARCH=arm64 go build gossa.go - mv gossa gossa-linux-arm64 - env GOOS=darwin GOARCH=amd64 go build gossa.go - mv gossa gossa-mac - env GOOS=windows GOARCH=amd64 go build gossa.go - mv gossa.exe gossa-windows.exe + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gossa-linux64 + env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o gossa-linux-arm + env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gossa-linux-arm64 + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o gossa-mac + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o gossa-windows.exe rm gossa.go clean: diff --git a/src/gossa_test.go b/src/gossa_test.go index f5c23a9..eb9dabf 100644 --- a/src/gossa_test.go +++ b/src/gossa_test.go @@ -6,12 +6,9 @@ import ( "fmt" "io/ioutil" "net/http" - "os" - "os/exec" "regexp" "strings" "testing" - "time" ) func dieMaybe(t *testing.T, err error) { @@ -132,7 +129,7 @@ func doTestRegular(t *testing.T, url string, testExtra bool) { // ~~~~~~~~~~~~~~~~~ fmt.Println("\r\n~~~~~~~~~~ test zip invalid path") body0 = get(t, url+"zip?zipPath=%2Ftmp&zipName=subdir") - if body0 == `ok` { + if body0 != `error` { t.Fatal("zip passed for invalid path") } @@ -318,33 +315,17 @@ func doTestReadonly(t *testing.T, url string) { fmt.Printf("\r\n=========\r\n") } -func startGossa(what string) int { - cmd := exec.Command("/usr/bin/make", what) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stdout - cmd.Start() - time.Sleep(3 * time.Second) - return cmd.Process.Pid -} - -func killallgossa() { - cmd := exec.Command("/usr/bin/killall", "gossa") - cmd.Start() -} - -func TestGossa(t *testing.T) { - startGossa("run") +func TestNormal(t *testing.T) { fmt.Println("========== testing normal path ============") doTestRegular(t, "http://127.0.0.1:8001/", false) - killallgossa() +} - startGossa("run-extra") +func TestExtra(t *testing.T) { fmt.Println("========== testing extras options ============") doTestRegular(t, "http://127.0.0.1:8001/fancy-path/", true) - killallgossa() +} - startGossa("run-ro") +func TestRo(t *testing.T) { fmt.Println("========== testing read only ============") doTestReadonly(t, "http://127.0.0.1:8001/") - killallgossa() }