rider partner
This commit is contained in:
41
repositories/partnerOnboard_test.go
Normal file
41
repositories/partnerOnboard_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"nearle/models"
|
||||
)
|
||||
|
||||
/*
|
||||
One partner, one district.
|
||||
|
||||
The form used to ask for a home region AND a coverage set, which put the same
|
||||
partner in `partnerinfo.applocationid` and several `partnerlocations` rows. A
|
||||
partner works one district — that is the operating rule — so the two writes
|
||||
carry the same single id and `regionsOf` is what guarantees they cannot
|
||||
disagree.
|
||||
*/
|
||||
|
||||
func TestRegionsOfIsTheOneDistrict(t *testing.T) {
|
||||
got := regionsOf(models.NewPartner{Applocationid: 2})
|
||||
if len(got) != 1 || got[0] != 2 {
|
||||
t.Fatalf("got %v, want [2]", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Zero is not a district. It arrives from a form field nobody filled in, and a
|
||||
// partnerlocations row pointing at region 0 would join to nothing for ever.
|
||||
func TestRegionsOfIgnoresZero(t *testing.T) {
|
||||
if got := regionsOf(models.NewPartner{Applocationid: 0}); len(got) != 0 {
|
||||
t.Fatalf("got %v, want none", got)
|
||||
}
|
||||
}
|
||||
|
||||
// A district sent only by NAME has not been resolved yet — CreatePartner opens
|
||||
// it and sets the id before this is reached. Until then there is no region, and
|
||||
// saying so beats guessing one.
|
||||
func TestRegionsOfDoesNotInventOneFromAName(t *testing.T) {
|
||||
if got := regionsOf(models.NewPartner{District: "Erode"}); len(got) != 0 {
|
||||
t.Fatalf("got %v, want none until the district is opened", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user