Format Go with gofmt, then golines -m 77 (closes #215)
check / check (push) Failing after 1m34s
check / check (push) Failing after 1m34s
script/fmt now runs golines -m 77 after gofmt, repeating golines until it changes nothing, since one pass can leave a line the next splits. script/fmt-check fails when either would change a file. script/bootstrap installs golines v0.13.0 with go install, pinned to its commit, and checks the installed version with go version -m. The tree is reformatted. The longer lines this makes are fixed by hand: nolint directives moved onto their own line above the statement, one string split, and 20 functions over funlen's 80 lines shortened or split, RunWAF and limitPercentages among them. Model: opus-5-5
This commit is contained in:
1 parent
63e58e326b
commit
7f8a59de04
118 files changed
+9447
-2670
No files matched your search
@@ -94,7 +94,10 @@ func TestHealthCheckInRProxysContainer(t *testing.T) {
|
||||
site, _ := startRProxy(t, "http://127.0.0.1:9", app.URL)
|
||||
_, port, _ := net.SplitHostPort(strings.TrimPrefix(site, "http://"))
|
||||
settings := func(more ...string) map[string]string {
|
||||
env := map[string]string{rproxyListenAddr: ":" + port, rproxyUpstreamURL: app.URL}
|
||||
env := map[string]string{
|
||||
rproxyListenAddr: ":" + port,
|
||||
rproxyUpstreamURL: app.URL,
|
||||
}
|
||||
for i := 0; i < len(more); i += 2 {
|
||||
env[more[i]] = more[i+1]
|
||||
}
|
||||
@@ -107,8 +110,12 @@ func TestHealthCheckInRProxysContainer(t *testing.T) {
|
||||
wantHealthCheck(t, settings(commandSetting, "rproxy"), 0, "")
|
||||
|
||||
// SWW_COMMAND cannot be given as a file.
|
||||
wantHealthCheck(t, settings(commandSetting+"_FILE", writeFile(t, "waf\n")),
|
||||
0, "")
|
||||
wantHealthCheck(
|
||||
t,
|
||||
settings(commandSetting+"_FILE", writeFile(t, "waf\n")),
|
||||
0,
|
||||
"",
|
||||
)
|
||||
|
||||
// Another setting does not fail it, even an invalid one, and neither does
|
||||
// SWRP_WAF_BACKEND being unset.
|
||||
@@ -121,7 +128,12 @@ func TestHealthCheckInRProxysContainer(t *testing.T) {
|
||||
|
||||
// Listening on port 0 takes any free port, so nothing listens on port 0
|
||||
// itself.
|
||||
wantHealthCheck(t, settings(rproxyListenAddr, ":0"), 1, "unhealthy: ask rproxy: ")
|
||||
wantHealthCheck(
|
||||
t,
|
||||
settings(rproxyListenAddr, ":0"),
|
||||
1,
|
||||
"unhealthy: ask rproxy: ",
|
||||
)
|
||||
wantHealthCheck(t, settings(rproxyListenAddr, "8080"), 1,
|
||||
"unhealthy: invalid setting: SWRP_LISTEN_ADDR: ")
|
||||
|
||||
@@ -161,16 +173,26 @@ func TestHealthCheckRefusesAnArgument(t *testing.T) {
|
||||
// wantHealthCheck runs the health check with the settings in env, and
|
||||
// checks its exit status and the start of what it writes to stderr,
|
||||
// which is nothing when message is empty.
|
||||
func wantHealthCheck(t *testing.T, env map[string]string, status int, message string) {
|
||||
func wantHealthCheck(
|
||||
t *testing.T,
|
||||
env map[string]string,
|
||||
status int,
|
||||
message string,
|
||||
) {
|
||||
t.Helper()
|
||||
|
||||
var stderr bytes.Buffer
|
||||
|
||||
got := sww.HealthCheck(t.Context(), nil, func(name string) (string, bool) {
|
||||
value, ok := env[name]
|
||||
got := sww.HealthCheck(
|
||||
t.Context(),
|
||||
nil,
|
||||
func(name string) (string, bool) {
|
||||
value, ok := env[name]
|
||||
|
||||
return value, ok
|
||||
}, &stderr)
|
||||
return value, ok
|
||||
},
|
||||
&stderr,
|
||||
)
|
||||
|
||||
wrote := stderr.String()
|
||||
if got != status || !strings.HasPrefix(wrote, message) ||
|
||||
|
||||
Reference in new issue
Block a user