package controllers import "testing" /* A rider belongs to a shop or to a delivery partner — never to neither, never to both. `CreateRider` used to demand a tenantid outright, which made a partner's rider impossible to create: a partner supplies riders to many merchants and their riders sit under no single one. The two ids are now exclusive, and both mistakes are refused rather than one being silently preferred — a rider carrying both appears in two directories and two assign pickers, with nothing downstream saying which owns them. `riderOwner` is the rule on its own so it can be checked without a request. */ func TestRiderOwnerAcceptsAShopsOwnRider(t *testing.T) { if err := riderOwner(1147, 0); err != nil { t.Fatalf("a tenant's own rider is valid: %v", err) } } func TestRiderOwnerAcceptsAPartnersRider(t *testing.T) { if err := riderOwner(0, 44); err != nil { t.Fatalf("a partner's rider is valid: %v", err) } } func TestRiderOwnerRefusesNeither(t *testing.T) { if err := riderOwner(0, 0); err == nil { t.Fatal("a rider owned by nobody appears in no directory and must be refused") } } func TestRiderOwnerRefusesBoth(t *testing.T) { if err := riderOwner(1147, 44); err == nil { t.Fatal("a rider owned by both appears in two pickers and must be refused") } }