Compare commits

...

2 Commits

Author SHA1 Message Date
s1d3sw1ped 466d69c44c make fmt
Format / gofmt (push) Successful in 7s
CI / Build (push) Successful in 14s
CI / Go Tests (push) Successful in 28s
2026-06-08 00:39:41 -05:00
s1d3sw1ped abb0256f0b add fmt and test-both to makefile to simplify tests and formatting 2026-06-08 00:39:28 -05:00
6 changed files with 36 additions and 16 deletions
+2 -2
View File
@@ -36,8 +36,8 @@ jobs:
- name: Build UI assets - name: Build UI assets
run: npm --prefix ./ui run build run: npm --prefix ./ui run build
- name: Run tests - name: Run Go Tests
run: make test run: make test-both
build: build:
name: Build name: Build
+22 -2
View File
@@ -1,4 +1,4 @@
.PHONY: build ui ui-build run docker docker-build test clean help .PHONY: build ui ui-build run docker docker-build test test-race test-both fmt clean help
APP_NAME := helix-proxy APP_NAME := helix-proxy
GO := go GO := go
@@ -22,6 +22,9 @@ help:
@echo " docker Build docker image (helix-proxy:dev)" @echo " docker Build docker image (helix-proxy:dev)"
@echo " docker-build Build docker image" @echo " docker-build Build docker image"
@echo " test Run go tests" @echo " test Run go tests"
@echo " test-race Run go tests with race detector"
@echo " test-both Run go tests and race detector"
@echo " fmt Format Go sources (gofmt)"
@echo " clean Remove build artifacts and ui/dist" @echo " clean Remove build artifacts and ui/dist"
@echo "" @echo ""
@@ -50,7 +53,24 @@ docker docker-build:
docker build -t helix-proxy:dev . docker build -t helix-proxy:dev .
test: test:
$(GO) test ./... -count=1 -race -coverprofile=coverage.out $(GO) test ./... -count=1
test-race:
$(GO) test ./... -count=1 -race
test-both: test test-race
fmt:
@echo "Formatting Go sources..."
@files="$$(gofmt -l .)"; \
if [ -n "$$files" ]; then \
count=$$(echo "$$files" | wc -l); \
echo "Reformatted $$count file(s):"; \
echo "$$files" | sed 's/^/ /'; \
echo "$$files" | xargs gofmt -w; \
else \
echo "All Go files already formatted."; \
fi
clean: clean:
rm -f $(APP_NAME) rm -f $(APP_NAME)
+5 -5
View File
@@ -118,11 +118,11 @@ func TestAPI_ErrorPaths(t *testing.T) {
assertStatus(t, apiPost(t, env.BaseURL+"/api/redirection-hosts/bad/enable", nil, token), http.StatusBadRequest) assertStatus(t, apiPost(t, env.BaseURL+"/api/redirection-hosts/bad/enable", nil, token), http.StatusBadRequest)
first := apiPost(t, env.BaseURL+"/api/redirection-hosts", map[string]any{ first := apiPost(t, env.BaseURL+"/api/redirection-hosts", map[string]any{
"domainNames": []string{"dup-redir.example"}, "domainNames": []string{"dup-redir.example"},
"forwardDomainName": "target.example", "forwardDomainName": "target.example",
"forwardScheme": "https", "forwardScheme": "https",
"preservePath": true, "preservePath": true,
"enabled": true, "enabled": true,
}, token) }, token)
if first.StatusCode != http.StatusCreated { if first.StatusCode != http.StatusCreated {
t.Fatalf("redir create: %d %s", first.StatusCode, readBody(first)) t.Fatalf("redir create: %d %s", first.StatusCode, readBody(first))
+1 -1
View File
@@ -19,7 +19,7 @@ import (
type testServerMode int type testServerMode int
const ( const (
testServerAPI testServerMode = iota testServerAPI testServerMode = iota
testServerAdmin testServerAdmin
) )
+2 -2
View File
@@ -95,8 +95,8 @@ func NewEngine(st store.Store) *Engine {
return &Engine{ return &Engine{
hosts: make(map[string]*Host), hosts: make(map[string]*Host),
st: st, st: st,
streamHandles: make(map[int]*streamHandle), streamHandles: make(map[int]*streamHandle),
streamRuntime: make(map[int]*streamRuntime), streamRuntime: make(map[int]*streamRuntime),
hostCerts: make(map[string]*tls.Certificate), hostCerts: make(map[string]*tls.Certificate),
certByID: make(map[int]*tls.Certificate), certByID: make(map[int]*tls.Certificate),
redirHosts: make(map[string]store.RedirectionHost), redirHosts: make(map[string]store.RedirectionHost),
+4 -4
View File
@@ -9,10 +9,10 @@ import (
) )
var ( var (
ErrDuplicateProxySource = errors.New("duplicate proxy host source domain") ErrDuplicateProxySource = errors.New("duplicate proxy host source domain")
ErrDuplicateRedirectionSource = errors.New("duplicate redirection host source domain") ErrDuplicateRedirectionSource = errors.New("duplicate redirection host source domain")
ErrDuplicateDeadSource = errors.New("duplicate dead host source domain") ErrDuplicateDeadSource = errors.New("duplicate dead host source domain")
ErrDuplicateStreamPort = errors.New("duplicate stream incoming port") ErrDuplicateStreamPort = errors.New("duplicate stream incoming port")
) )
func IsConflictError(err error) bool { func IsConflictError(err error) bool {