Files
seaweedfs/seaweed-block/cmd/blockmaster/removed_flag_test.go
T
pingqiuandClaude Opus 5.5 d08cee2315 blockmaster: refuse the removed --workspace-head-base-url at start
v1 reads HEAD through the layout catalog. A unit or script that still
passes the removed flag is refused at start with a typed error
(errRemovedInV1) that names the replacement, --chunk-filer and
--chunk-path, rather than Go's generic unknown-flag message; the flag
is never accepted and ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:53:01 -08:00

36 lines
1.4 KiB
Go

package main
import (
"errors"
"strings"
"testing"
)
// v1 removed --workspace-head-base-url (blockmaster reads HEAD through the
// layout catalog). A unit or script still passing it is refused at start
// with a typed error that names the replacement, in either flag form; it is
// never accepted and ignored.
func TestRemovedHeadBaseURLFlagIsRefusedAtStart(t *testing.T) {
base := func(extra ...string) []string {
return append([]string{"--authority-store", t.TempDir()}, extra...)
}
if _, err := parseFlags(base()); err != nil {
t.Fatalf("control without the removed flag: %v", err)
}
for name, args := range map[string][]string{
"name=value": base("--workspace-head-base-url=http://filer:8888/swblock/chunks"),
"name value": base("--workspace-head-base-url", "http://filer:8888/swblock/chunks"),
"empty value": base("--workspace-head-base-url="),
"single dash": base("-workspace-head-base-url=http://filer:8888/swblock/chunks"),
"after others": base("--workspace-rpc", "--workspace-head-base-url=http://filer:8888/swblock/chunks"),
} {
_, err := parseFlags(args)
if !errors.Is(err, errRemovedInV1) {
t.Fatalf("%s: %v; want the removed-in-v1 refusal", name, err)
}
if !strings.Contains(err.Error(), "--workspace-head-base-url") || !strings.Contains(err.Error(), "--chunk-filer") {
t.Fatalf("%s: %q; want it to name the removed flag and its replacement", name, err)
}
}
}