Why: the help text advertised --gated on bd mol ready but Cobra flags do not propagate between sibling commands, so the advertised flag was a hard error; this registers it on molReadyGatedCmd directly. Landed manually (auto-merge disabled) after the branch was updated past the #4623 main-CI fixes and the full check suite ran green. Co-Authored-By: Scott Hamilton <scotthamilton77@gmail.com> Co-Authored-By: matt wilkie <maphew@gmail.com>
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// TestMolReadyGatedFlagRegistered guards against the regression where the
|
|
// `bd mol ready --gated` help text advertised the flag but no flag was
|
|
// registered on the subcommand, so the runtime rejected --gated as unknown.
|
|
//
|
|
// Both spellings — `bd ready --gated` (registered on readyCmd in ready.go)
|
|
// and `bd mol ready --gated` (registered here) — must accept the flag.
|
|
func TestMolReadyGatedFlagRegistered(t *testing.T) {
|
|
flag := molReadyGatedCmd.Flags().Lookup("gated")
|
|
if flag == nil {
|
|
t.Fatal("`bd mol ready` is missing the --gated flag; cobra will reject `bd mol ready --gated` with 'unknown flag: --gated'")
|
|
}
|
|
if flag.Value.Type() != "bool" {
|
|
t.Errorf("--gated flag should be bool, got %s", flag.Value.Type())
|
|
}
|
|
}
|
|
|
|
// TestReadyGatedFlagRegistered guards the sibling spelling `bd ready --gated`,
|
|
// which is the path runMolReadyGated is dispatched from in ready.go.
|
|
func TestReadyGatedFlagRegistered(t *testing.T) {
|
|
flag := readyCmd.Flags().Lookup("gated")
|
|
if flag == nil {
|
|
t.Fatal("`bd ready` is missing the --gated flag; gate-resume discovery breaks")
|
|
}
|
|
if flag.Value.Type() != "bool" {
|
|
t.Errorf("--gated flag should be bool, got %s", flag.Value.Type())
|
|
}
|
|
}
|