fixup tests

This commit is contained in:
Pierre Dubouilh
2020-10-04 16:57:03 +02:00
committed by Pierre Dubouilh
parent c1eeb9820a
commit 97e24cc513
2 changed files with 22 additions and 37 deletions
+16 -12
View File
@@ -2,7 +2,7 @@ build:
cp src/gossa.go gossa.go cp src/gossa.go gossa.go
make -C gossa-ui/ make -C gossa-ui/
go vet && go fmt go vet && go fmt
CGO_ENABLED=0 go build gossa.go CGO_ENABLED=0 go build
rm gossa.go rm gossa.go
install: install:
@@ -22,7 +22,16 @@ test:
-rm gossa_test.go -rm gossa_test.go
-@cd test-fixture && ln -s ../support . -@cd test-fixture && ln -s ../support .
cp src/gossa_test.go . 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: watch:
ls src/* gossa-ui/* | entr -rc make build run ls src/* gossa-ui/* | entr -rc make build run
@@ -39,16 +48,11 @@ watch-test:
build-all: build-all:
cp src/gossa.go gossa.go cp src/gossa.go gossa.go
make -C gossa-ui/ make -C gossa-ui/
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build gossa.go env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gossa-linux64
mv gossa gossa-linux64 env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o gossa-linux-arm
env GOOS=linux GOARCH=arm go build gossa.go env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gossa-linux-arm64
mv gossa gossa-linux-arm env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o gossa-mac
env GOOS=linux GOARCH=arm64 go build gossa.go env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o gossa-windows.exe
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
rm gossa.go rm gossa.go
clean: clean:
+6 -25
View File
@@ -6,12 +6,9 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os"
"os/exec"
"regexp" "regexp"
"strings" "strings"
"testing" "testing"
"time"
) )
func dieMaybe(t *testing.T, err error) { 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") fmt.Println("\r\n~~~~~~~~~~ test zip invalid path")
body0 = get(t, url+"zip?zipPath=%2Ftmp&zipName=subdir") body0 = get(t, url+"zip?zipPath=%2Ftmp&zipName=subdir")
if body0 == `ok` { if body0 != `error` {
t.Fatal("zip passed for invalid path") t.Fatal("zip passed for invalid path")
} }
@@ -318,33 +315,17 @@ func doTestReadonly(t *testing.T, url string) {
fmt.Printf("\r\n=========\r\n") fmt.Printf("\r\n=========\r\n")
} }
func startGossa(what string) int { func TestNormal(t *testing.T) {
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")
fmt.Println("========== testing normal path ============") fmt.Println("========== testing normal path ============")
doTestRegular(t, "http://127.0.0.1:8001/", false) doTestRegular(t, "http://127.0.0.1:8001/", false)
killallgossa() }
startGossa("run-extra") func TestExtra(t *testing.T) {
fmt.Println("========== testing extras options ============") fmt.Println("========== testing extras options ============")
doTestRegular(t, "http://127.0.0.1:8001/fancy-path/", true) 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 ============") fmt.Println("========== testing read only ============")
doTestReadonly(t, "http://127.0.0.1:8001/") doTestReadonly(t, "http://127.0.0.1:8001/")
killallgossa()
} }