Fix tests
This commit is contained in:
@@ -41,9 +41,8 @@ modified = true
|
||||
`,
|
||||
expected: `{
|
||||
"name": "test",
|
||||
"value": 42,
|
||||
"newField": "added"
|
||||
}`,
|
||||
"value": 42
|
||||
,"newField":"added"}`, // sjson.Set() adds new fields in compact format
|
||||
},
|
||||
{
|
||||
name: "Modify nested field",
|
||||
@@ -93,19 +92,9 @@ modified = true
|
||||
result = result[:cmd.From] + cmd.With + result[cmd.To:]
|
||||
}
|
||||
|
||||
// Instead of exact string comparison, check that key values are present
|
||||
// This accounts for field ordering differences in JSON
|
||||
if !contains(result, `"value": 84`) && tt.name == "Modify single field" {
|
||||
t.Errorf("Expected value to be 84, got:\n%s", result)
|
||||
}
|
||||
if !contains(result, `"newField": "added"`) && tt.name == "Add new field" {
|
||||
t.Errorf("Expected newField to be added, got:\n%s", result)
|
||||
}
|
||||
if !contains(result, `"enabled": true`) && tt.name == "Modify nested field" {
|
||||
t.Errorf("Expected enabled to be true, got:\n%s", result)
|
||||
}
|
||||
if !contains(result, `"timeout": 60`) && tt.name == "Modify nested field" {
|
||||
t.Errorf("Expected timeout to be 60, got:\n%s", result)
|
||||
// Check the actual result matches expected
|
||||
if result != tt.expected {
|
||||
t.Errorf("Expected:\n%s\n\nGot:\n%s", tt.expected, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user