@@ -24,8 +24,6 @@ func newTestStore(t *testing.T) *data.Store {
2424 return store
2525}
2626
27- func jn (s string ) json.Number { return json .Number (s ) }
28-
2927func TestShadowDB_NewAndClose (t * testing.T ) {
3028 t .Parallel ()
3129 store := newTestStore (t )
@@ -82,7 +80,7 @@ func TestShadowDB_StageSkipsUpdates(t *testing.T) {
8280
8381 ops := []Operation {
8482 {Action : ActionUpdate , Table : data .TableDocuments , Data : map [string ]any {
85- "id" : jn ("42" ),
83+ "id" : json . Number ("42" ),
8684 "title" : "Updated Title" ,
8785 }},
8886 }
@@ -154,7 +152,7 @@ func TestShadowDB_CommitVendorThenQuote_CrossReference(t *testing.T) {
154152 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
155153 "vendor_id" : "1" ,
156154 "project_id" : projectID ,
157- "total_cents" : jn ("150000" ),
155+ "total_cents" : json . Number ("150000" ),
158156 }},
159157 }
160158 require .NoError (t , sdb .Stage (ops ))
@@ -197,7 +195,7 @@ func TestShadowDB_CommitApplianceThenMaintenance_CrossReference(t *testing.T) {
197195 "name" : "Replace HVAC Filter" ,
198196 "appliance_id" : "1" ,
199197 "category_id" : catID ,
200- "interval_months" : jn ("3" ),
198+ "interval_months" : json . Number ("3" ),
201199 }},
202200 }
203201 require .NoError (t , sdb .Stage (ops ))
@@ -244,12 +242,12 @@ func TestShadowDB_CommitMultipleVendorsAndQuotes(t *testing.T) {
244242 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
245243 "vendor_id" : "1" ,
246244 "project_id" : projectID ,
247- "total_cents" : jn ("100000" ),
245+ "total_cents" : json . Number ("100000" ),
248246 }},
249247 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
250248 "vendor_id" : "2" ,
251249 "project_id" : projectID ,
252- "total_cents" : jn ("200000" ),
250+ "total_cents" : json . Number ("200000" ),
253251 }},
254252 }
255253 require .NoError (t , sdb .Stage (ops ))
@@ -353,7 +351,7 @@ func TestShadowDB_CommitDocumentWithEntityRemap(t *testing.T) {
353351 {Action : ActionCreate , Table : data .TableDocuments , Data : map [string ]any {
354352 "title" : "Vendor Invoice" ,
355353 "entity_kind" : "vendor" ,
356- "entity_id" : jn ("1" ),
354+ "entity_id" : json . Number ("1" ),
357355 }},
358356 }
359357 require .NoError (t , sdb .Stage (ops ))
@@ -401,7 +399,7 @@ func TestShadowDB_CommitQuoteWithExistingVendorByID(t *testing.T) {
401399 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
402400 "vendor_id" : realVendorID ,
403401 "project_id" : projectID ,
404- "total_cents" : jn ("50000" ),
402+ "total_cents" : json . Number ("50000" ),
405403 }},
406404 }
407405 require .NoError (t , sdb .Stage (ops ))
@@ -436,7 +434,7 @@ func TestShadowDB_CommitQuoteWithVendorName(t *testing.T) {
436434 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
437435 "vendor_name" : "New Plumber" ,
438436 "project_id" : projectID ,
439- "total_cents" : jn ("75000" ),
437+ "total_cents" : json . Number ("75000" ),
440438 }},
441439 }
442440 require .NoError (t , sdb .Stage (ops ))
@@ -567,7 +565,7 @@ func TestShadowDB_OffsetCrossReference(t *testing.T) {
567565 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
568566 "vendor_id" : "4" ,
569567 "project_id" : projectID ,
570- "total_cents" : jn ("99000" ),
568+ "total_cents" : json . Number ("99000" ),
571569 }},
572570 }
573571 require .NoError (t , sdb .Stage (ops ))
@@ -623,7 +621,7 @@ func TestShadowDB_OffsetExistingVendorNotRemapped(t *testing.T) {
623621 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
624622 "vendor_id" : existingVendorID ,
625623 "project_id" : projectID ,
626- "total_cents" : jn ("50000" ),
624+ "total_cents" : json . Number ("50000" ),
627625 }},
628626 }
629627 require .NoError (t , sdb .Stage (ops ))
@@ -686,7 +684,7 @@ func TestShadowDB_CommitDuplicateMaintenanceUsesExisting(t *testing.T) {
686684 {Action : ActionCreate , Table : data .TableMaintenanceItems , Data : map [string ]any {
687685 "name" : "Replace Filter" ,
688686 "category_id" : catID ,
689- "interval_months" : jn ("6" ),
687+ "interval_months" : json . Number ("6" ),
690688 }},
691689 }
692690 require .NoError (t , sdb .Stage (ops ))
@@ -714,7 +712,7 @@ func TestShadowDB_CommitRollsBackOnFailure(t *testing.T) {
714712 "name" : "Should Be Rolled Back" ,
715713 }},
716714 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
717- "total_cents" : jn ("50000" ),
715+ "total_cents" : json . Number ("50000" ),
718716 }},
719717 }
720718 require .NoError (t , sdb .Stage (ops ))
@@ -733,9 +731,9 @@ func TestShadowDB_NormalizeValueHandlesJSONNumber(t *testing.T) {
733731 input any
734732 expected any
735733 }{
736- {jn ("42" ), int64 (42 )},
737- {jn ("-7" ), int64 (- 7 )},
738- {jn ("3.14" ), "3.14" },
734+ {json . Number ("42" ), int64 (42 )},
735+ {json . Number ("-7" ), int64 (- 7 )},
736+ {json . Number ("3.14" ), "3.14" },
739737 {"hello" , "hello" },
740738 {nil , nil },
741739 {true , true },
@@ -907,7 +905,7 @@ func TestShadowDB_CommitReversedOrder_QuoteBeforeVendor(t *testing.T) {
907905 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
908906 "vendor_id" : "1" ,
909907 "project_id" : projectID ,
910- "total_cents" : jn ("150000" ),
908+ "total_cents" : json . Number ("150000" ),
911909 }},
912910 {Action : ActionCreate , Table : data .TableVendors , Data : map [string ]any {
913911 "name" : "Garcia Plumbing" ,
@@ -945,7 +943,7 @@ func TestShadowDB_CommitReversedOrder_MaintenanceBeforeAppliance(t *testing.T) {
945943 "name" : "Replace HVAC Filter" ,
946944 "appliance_id" : "1" ,
947945 "category_id" : catID ,
948- "interval_months" : jn ("3" ),
946+ "interval_months" : json . Number ("3" ),
949947 }},
950948 {Action : ActionCreate , Table : data .TableAppliances , Data : map [string ]any {
951949 "name" : "HVAC Unit" ,
@@ -1031,13 +1029,13 @@ func TestShadowDB_CommitReversedOrder_FullChain(t *testing.T) {
10311029 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
10321030 "vendor_id" : "1" ,
10331031 "project_id" : projectID ,
1034- "total_cents" : jn ("250000" ),
1032+ "total_cents" : json . Number ("250000" ),
10351033 }},
10361034 {Action : ActionCreate , Table : data .TableMaintenanceItems , Data : map [string ]any {
10371035 "name" : "Filter Change" ,
10381036 "appliance_id" : "1" ,
10391037 "category_id" : catID ,
1040- "interval_months" : jn ("6" ),
1038+ "interval_months" : json . Number ("6" ),
10411039 }},
10421040 {Action : ActionCreate , Table : data .TableAppliances , Data : map [string ]any {
10431041 "name" : "Furnace" ,
@@ -1088,9 +1086,9 @@ func TestShadowDB_CommitQuoteWithoutProjectID_Fails(t *testing.T) {
10881086 "name" : "Sierra Structures" ,
10891087 }},
10901088 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
1091- "vendor_id" : jn ("1" ),
1089+ "vendor_id" : json . Number ("1" ),
10921090 "vendor_name" : "Sierra Structures" ,
1093- "total_cents" : jn ("485400" ),
1091+ "total_cents" : json . Number ("485400" ),
10941092 }},
10951093 }
10961094 require .NoError (t , sdb .Stage (ops ))
@@ -1152,7 +1150,7 @@ func TestShadowDB_CommitProject(t *testing.T) {
11521150 "project_type_id" : types [0 ].ID ,
11531151 "status" : data .ProjectStatusPlanned ,
11541152 "description" : "Install a cedar fence" ,
1155- "budget_cents" : jn ("500000" ),
1153+ "budget_cents" : json . Number ("500000" ),
11561154 }},
11571155 }
11581156 require .NoError (t , sdb .Stage (ops ))
@@ -1215,7 +1213,7 @@ func TestShadowDB_CommitProjectThenQuote_CrossReference(t *testing.T) {
12151213 {Action : ActionCreate , Table : data .TableQuotes , Data : map [string ]any {
12161214 "vendor_id" : "1" ,
12171215 "project_id" : "1" ,
1218- "total_cents" : jn ("350000" ),
1216+ "total_cents" : json . Number ("350000" ),
12191217 }},
12201218 }
12211219 require .NoError (t , sdb .Stage (ops ))
@@ -1246,7 +1244,7 @@ func TestShadowDB_CommitIncident(t *testing.T) {
12461244 "status" : data .IncidentStatusOpen ,
12471245 "severity" : data .IncidentSeverityUrgent ,
12481246 "location" : "Basement" ,
1249- "cost_cents" : jn ("250000" ),
1247+ "cost_cents" : json . Number ("250000" ),
12501248 "date_noticed" : "2026-01-15" ,
12511249 }},
12521250 }
@@ -1339,7 +1337,7 @@ func TestShadowDB_CommitServiceLog(t *testing.T) {
13391337 {Action : ActionCreate , Table : data .TableServiceLogEntries , Data : map [string ]any {
13401338 "maintenance_item_id" : itemID ,
13411339 "serviced_at" : "2026-02-20" ,
1342- "cost_cents" : jn ("15000" ),
1340+ "cost_cents" : json . Number ("15000" ),
13431341 "notes" : "Replaced filter" ,
13441342 "vendor_name" : "HVAC Pro" ,
13451343 }},
@@ -1460,7 +1458,7 @@ func TestShadowDB_CommitUpdateQuote(t *testing.T) {
14601458 ops := []Operation {
14611459 {Action : ActionUpdate , Table : data .TableQuotes , Data : map [string ]any {
14621460 "id" : q .ID ,
1463- "total_cents" : jn ("125000" ),
1461+ "total_cents" : json . Number ("125000" ),
14641462 "notes" : "Revised estimate after site visit" ,
14651463 }},
14661464 }
0 commit comments