Fix Arch package test failures
This commit is contained in:
@@ -27,8 +27,12 @@ sha256sums=(
|
|||||||
|
|
||||||
pkgver() {
|
pkgver() {
|
||||||
cd skald || return
|
cd skald || return
|
||||||
git describe --long --tags 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
|
local describe
|
||||||
|
if describe="$(git describe --long --tags 2>/dev/null)"; then
|
||||||
|
printf '%s\n' "$describe" | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
||||||
|
else
|
||||||
printf '0.0.0.r%s.g%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
printf '0.0.0.r%s.g%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
|||||||
+18
-6
@@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -20,19 +21,30 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var setupOnce sync.Once
|
var setupOnce sync.Once
|
||||||
|
var setupErr error
|
||||||
|
var testServerURL string
|
||||||
|
|
||||||
func setup() {
|
func setup() error {
|
||||||
setupOnce.Do(func() {
|
setupOnce.Do(func() {
|
||||||
Insecure = true
|
Insecure = true
|
||||||
err := Serve("localhost:1234", "")
|
listener, err := net.Listen("tcp", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("could not start server")
|
setupErr = fmt.Errorf("listen test server: %w", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
testServerURL = "http://" + listener.Addr().String()
|
||||||
|
setupErr = serve(listener, listener.Addr().String(), "")
|
||||||
|
if setupErr != nil {
|
||||||
|
listener.Close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
return setupErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupTest(dir, datadir string) error {
|
func setupTest(dir, datadir string) error {
|
||||||
setup()
|
if err := setup(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
hall.Directory = dir
|
hall.Directory = dir
|
||||||
hall.DataDirectory = datadir
|
hall.DataDirectory = datadir
|
||||||
@@ -77,7 +89,7 @@ func TestApi(t *testing.T) {
|
|||||||
|
|
||||||
do := func(method, path, ctype, im, inm, body string) (*http.Response, error) {
|
do := func(method, path, ctype, im, inm, body string) (*http.Response, error) {
|
||||||
req, err := http.NewRequest(method,
|
req, err := http.NewRequest(method,
|
||||||
"http://localhost:1234"+path,
|
testServerURL+path,
|
||||||
strings.NewReader(body),
|
strings.NewReader(body),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -430,7 +442,7 @@ func TestApiBadAuth(t *testing.T) {
|
|||||||
|
|
||||||
do := func(method, path string) {
|
do := func(method, path string) {
|
||||||
req, err := http.NewRequest(method,
|
req, err := http.NewRequest(method,
|
||||||
"http://localhost:1234"+path,
|
testServerURL+path,
|
||||||
nil)
|
nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("New request: %v", err)
|
t.Errorf("New request: %v", err)
|
||||||
|
|||||||
+15
-11
@@ -34,6 +34,19 @@ var StaticRoot string
|
|||||||
var Insecure bool
|
var Insecure bool
|
||||||
|
|
||||||
func Serve(address string, dataDir string) error {
|
func Serve(address string, dataDir string) error {
|
||||||
|
proto := "tcp"
|
||||||
|
if strings.HasPrefix(address, "/") {
|
||||||
|
proto = "unix"
|
||||||
|
}
|
||||||
|
|
||||||
|
listener, err := net.Listen(proto, address)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return serve(listener, address, dataDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
func serve(listener net.Listener, address string, dataDir string) error {
|
||||||
http.Handle("/", &fileHandler{http.Dir(StaticRoot)})
|
http.Handle("/", &fileHandler{http.Dir(StaticRoot)})
|
||||||
http.HandleFunc("/hall/", hallHandler)
|
http.HandleFunc("/hall/", hallHandler)
|
||||||
http.HandleFunc("/recordings",
|
http.HandleFunc("/recordings",
|
||||||
@@ -69,21 +82,12 @@ func Serve(address string, dataDir string) error {
|
|||||||
|
|
||||||
server = s
|
server = s
|
||||||
|
|
||||||
proto := "tcp"
|
|
||||||
if strings.HasPrefix(address, "/") {
|
|
||||||
proto = "unix"
|
|
||||||
}
|
|
||||||
|
|
||||||
listener, err := net.Listen(proto, address)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
go func() {
|
go func() {
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
if !Insecure {
|
if !Insecure {
|
||||||
err = s.ServeTLS(listener, "", "")
|
_ = s.ServeTLS(listener, "", "")
|
||||||
} else {
|
} else {
|
||||||
err = s.Serve(listener)
|
_ = s.Serve(listener)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user