mirror of
https://github.com/pldubouilh/gossa
synced 2026-01-03 14:12:19 +01:00
fixup tests
This commit is contained in:
parent
c1eeb9820a
commit
97e24cc513
2 changed files with 22 additions and 37 deletions
28
Makefile
28
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:
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue