package hostbox import ( "context" "errors" "github.com/carlosframework/platform/internal/hostwrite" "testing" ) func TestStartupFlagOnceAndInert(t *testing.T) { for _, value := range []string{"", " ", "0", "1"} { reads, calls := 0, 0 cfg, err := Startup(context.Background(), func(name string) string { reads++ if name != "CARLOS_HOST_CLAIM" { t.Fatal(name) } return value }, func(context.Context) (hostwrite.Selector, error) { calls++; return nil, hostwrite.ErrUnavailable }) on := value == "0" || value == "1" if reads != 1 || cfg.Enabled != on || (calls == 1) != on || (err != nil) != on { t.Fatalf("%q: %+v %v %d %d", value, cfg, err, reads, calls) } } } type refuseRoster struct{} func (refuseRoster) Actor(context.Context, string) (Actor, error) { return Actor{}, errors.New("unverified roster") } func TestIdentityHasNoRegionOnlyFallback(t *testing.T) { if _, err := (IdentityProvider{Box: "box", Region: "ie", Roster: refuseRoster{}}).Verify(context.Background()); err == nil { t.Fatal("identity without boxid evidence") } }