updates on the onboardings and hubs patches as well

This commit is contained in:
2026-10-06 19:11:18 +05:30
parent 7ff9dad288
commit 0326624ca3
6 changed files with 559 additions and 31 deletions

View File

@@ -81,6 +81,7 @@ func TestOnboardedClientRowMapsEveryColumn(t *testing.T) {
for _, col := range []string{
"authid", "tenantid", "tenantname", "primaryemail", "primarycontact", "status",
"requiredeliveryotp", "contactname", "loginemail", "loginrole", "authcreatedat", "tenantcreatedat",
"address", "city", "state", "pincode", "latitude", "longitude",
} {
if s.LookUpField(col) == nil {
t.Errorf("column %q selected by the list query maps to no field", col)
@@ -104,3 +105,34 @@ func TestOnboardedClientRowToClient(t *testing.T) {
t.Fatal("no real date must give null, not year 1")
}
}
func TestClientAddressValidate(t *testing.T) {
ok := clientAddress{Address: " 14 DB Road, RS Puram ", City: " Coimbatore ", State: "Tamil Nadu",
Pincode: " 641 002", Latitude: 11.009, Longitude: 76.95}
if msg := ok.validate(); msg != "" {
t.Fatalf("valid address refused: %s", msg)
}
if ok.Address != "14 DB Road, RS Puram" || ok.City != "Coimbatore" || ok.State != "Tamil Nadu" || ok.Pincode != "641002" {
t.Fatalf("not normalised: %+v", ok)
}
cases := []struct {
name string
a clientAddress
want string
}{
{"empty", clientAddress{}, "enter the client's address"},
{"too short", clientAddress{Address: "abc", Pincode: "641002", Latitude: 11, Longitude: 77}, "enter the client's address"},
{"too long", clientAddress{Address: strings.Repeat("a", 301), Pincode: "641002", Latitude: 11, Longitude: 77}, "too long"},
{"pincode 5 digits", clientAddress{Address: "14 DB Road", Pincode: "64100", Latitude: 11, Longitude: 77}, "6-digit pincode"},
{"pincode starts 0", clientAddress{Address: "14 DB Road", Pincode: "041002", Latitude: 11, Longitude: 77}, "6-digit pincode"},
{"no map location", clientAddress{Address: "14 DB Road", Pincode: "641002"}, "pick the address"},
{"swapped lat/lon", clientAddress{Address: "14 DB Road", Pincode: "641002", Latitude: 76.95, Longitude: 11.0}, "pick the address"},
{"outside India", clientAddress{Address: "14 DB Road", Pincode: "641002", Latitude: 51.5, Longitude: -0.1}, "pick the address"},
}
for _, c := range cases {
a := c.a
if msg := a.validate(); !strings.Contains(msg, c.want) {
t.Errorf("%s: %q, want %q", c.name, msg, c.want)
}
}
}