rider partner

This commit is contained in:
2026-09-09 15:44:27 +05:30
parent 62a441d798
commit e7577fe0cf
11 changed files with 812 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
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")
}
}