feat: improve gas station management workflow
This commit is contained in:
@@ -50,6 +50,38 @@ func TestResourceResponseStripsInternalIDsRecursively(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicResourceResponsePreservesOnlyRecordID(t *testing.T) {
|
||||
got, err := PublicResourceResponse(map[string]any{
|
||||
"id": uint64(7), "identity": "record",
|
||||
"child": map[string]any{"id": uint64(8), "identity": "child"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
record := got.(map[string]any)
|
||||
if record["id"] != float64(7) {
|
||||
t.Fatalf("record ID = %#v, want 7", record["id"])
|
||||
}
|
||||
if _, exists := record["child"].(map[string]any)["id"]; exists {
|
||||
t.Fatal("nested database ID was exposed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicResourceResponsePreservesListRecordIDs(t *testing.T) {
|
||||
got, err := PublicResourceResponse([]map[string]any{
|
||||
{"id": uint64(11), "identity": "first"},
|
||||
{"id": uint64(12), "identity": "second"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
list := got.([]any)
|
||||
if list[0].(map[string]any)["id"] != float64(11) ||
|
||||
list[1].(map[string]any)["id"] != float64(12) {
|
||||
t.Fatalf("list record IDs were not preserved: %#v", list)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicFieldProtectionMasksGasorderContacts(t *testing.T) {
|
||||
value := map[string]any{"contact_name": "张三", "contact_phone": "13800138000"}
|
||||
ProtectPublicFields(value, false, false, false)
|
||||
|
||||
Reference in New Issue
Block a user