crabbox/internal/cli/flags_test.go
Jonathan Moss 00725544c7
feat(azure): support linux and native windows leases
Add Azure as a managed provider for direct and brokered Crabbox leases.

- provision Azure Linux VMs with cloud-init, spot fallback, shared network adoption, and per-lease cleanup
- provision native Azure Windows VMs with VM Agent bootstrap and SSH/sync/run support
- add Azure broker support in the Cloudflare Worker, provider config, docs, and tests
- fix async Azure delete handling so successful 202 delete LROs do not refetch deleted resources
- keep Go core coverage above the CI threshold

Verified with CI plus live Azure Linux and native Windows leases.

Co-authored-by: Jonathan Moss <2729151+jwmoss@users.noreply.github.com>
2026-05-08 08:23:38 +01:00

51 lines
1.1 KiB
Go

package cli
import (
"flag"
"testing"
)
func TestExtractBoolFlag(t *testing.T) {
args, found := extractBoolFlag([]string{"run_123", "--json", "--tail"}, "json")
if !found {
t.Fatalf("flag not found")
}
if len(args) != 2 || args[0] != "run_123" || args[1] != "--tail" {
t.Fatalf("args=%v", args)
}
}
func TestExtractBoolFlagMissing(t *testing.T) {
args, found := extractBoolFlag([]string{"run_123"}, "json")
if found {
t.Fatalf("flag should not be found")
}
if len(args) != 1 || args[0] != "run_123" {
t.Fatalf("args=%v", args)
}
}
func TestFlagWasSet(t *testing.T) {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
value := fs.String("id", "", "")
fs.Bool("json", false, "")
if err := fs.Parse([]string{"--id", "blue-lobster"}); err != nil {
t.Fatal(err)
}
if *value != "blue-lobster" {
t.Fatalf("id=%q", *value)
}
if !flagWasSet(fs, "id") {
t.Fatal("id should be marked set")
}
if !FlagWasSet(fs, "id") {
t.Fatal("exported id check should be marked set")
}
if flagWasSet(fs, "json") {
t.Fatal("json should not be marked set")
}
if FlagWasSet(fs, "json") {
t.Fatal("exported json check should not be marked set")
}
}