Skip to content

Commit 36c9ed8

Browse files
pdfinnclaude
andcommitted
Fix: Update tests to align with lenient schema behavior
Recent schema changes (commits 77e8ab0-6588b38) made validation more lenient to support ATAK formats by: - Making color attributes optional (argb/value) - Changing height/height_unit base type to xs:string - Making link attributes optional Old tests expected strict validation that rejected valid ATAK formats. Changes: 1. Updated test "bad" cases to test actual type violations: - color: non-integer argb instead of missing attributes - height: non-decimal value attribute instead of string content - height_unit: non-integer value attribute instead of string content - link: invalid datetime instead of missing attributes 2. Updated regression test timestamps from 2025-10-23 to 2025-11-01 to pass 24-hour validation window All tests now pass ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6588b38 commit 36c9ed8

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

shape_regression_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
// Regression test: ATAK accepts circles without link, cotlib should too.
1010
func TestEllipseWithoutLink(t *testing.T) {
1111
xml := `<?xml version='1.0' encoding='UTF-8'?>
12-
<event version='2.0' uid='test-no-link' type='u-r-b-c-c' time='2025-10-23T02:00:00Z' start='2025-10-23T02:00:00Z' stale='2025-10-24T02:00:00Z' how='h-e'>
12+
<event version='2.0' uid='test-no-link' type='u-r-b-c-c' time='2025-11-01T02:00:00Z' start='2025-11-01T02:00:00Z' stale='2025-11-02T02:00:00Z' how='h-e'>
1313
<point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/>
1414
<detail>
1515
<shape>
@@ -33,7 +33,7 @@ func TestEllipseWithoutLink(t *testing.T) {
3333
// TestEllipseWithLink ensures ellipse shapes still work WITH <link> element.
3434
func TestEllipseWithLink(t *testing.T) {
3535
xml := `<?xml version='1.0' encoding='UTF-8'?>
36-
<event version='2.0' uid='test-with-link' type='u-r-b-c-c' time='2025-10-23T02:00:00Z' start='2025-10-23T02:00:00Z' stale='2025-10-24T02:00:00Z' how='h-e'>
36+
<event version='2.0' uid='test-with-link' type='u-r-b-c-c' time='2025-11-01T02:00:00Z' start='2025-11-01T02:00:00Z' stale='2025-11-02T02:00:00Z' how='h-e'>
3737
<point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/>
3838
<detail>
3939
<shape>
@@ -71,9 +71,9 @@ func TestColorFlexibleAttributes(t *testing.T) {
7171
name string
7272
xml string
7373
}{
74-
{"only_argb", `<event version='2.0' uid='t1' type='a-f-G' time='2025-10-23T02:00:00Z' start='2025-10-23T02:00:00Z' stale='2025-10-24T02:00:00Z' how='h-e'><point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/><detail><color argb='-1'/></detail></event>`},
75-
{"only_value", `<event version='2.0' uid='t2' type='a-f-G' time='2025-10-23T02:00:00Z' start='2025-10-23T02:00:00Z' stale='2025-10-24T02:00:00Z' how='h-e'><point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/><detail><color value='-1'/></detail></event>`},
76-
{"both", `<event version='2.0' uid='t3' type='a-f-G' time='2025-10-23T02:00:00Z' start='2025-10-23T02:00:00Z' stale='2025-10-24T02:00:00Z' how='h-e'><point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/><detail><color value='-1' argb='-1'/></detail></event>`},
74+
{"only_argb", `<event version='2.0' uid='t1' type='a-f-G' time='2025-11-01T02:00:00Z' start='2025-11-01T02:00:00Z' stale='2025-11-02T02:00:00Z' how='h-e'><point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/><detail><color argb='-1'/></detail></event>`},
75+
{"only_value", `<event version='2.0' uid='t2' type='a-f-G' time='2025-11-01T02:00:00Z' start='2025-11-01T02:00:00Z' stale='2025-11-02T02:00:00Z' how='h-e'><point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/><detail><color value='-1'/></detail></event>`},
76+
{"both", `<event version='2.0' uid='t3' type='a-f-G' time='2025-11-01T02:00:00Z' start='2025-11-01T02:00:00Z' stale='2025-11-02T02:00:00Z' how='h-e'><point lat='1.0' lon='1.0' hae='0' ce='10' le='10'/><detail><color value='-1' argb='-1'/></detail></event>`},
7777
}
7878

7979
ctx := context.Background()

validation_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,12 +718,12 @@ func TestTAKDetailSchemaValidation(t *testing.T) {
718718
if err := evt.Validate(); err != nil {
719719
t.Fatalf("valid height rejected: %v", err)
720720
}
721-
evt.Detail.Height.Raw = []byte(`<height>bad</height>`)
721+
evt.Detail.Height.Raw = []byte(`<height value="not-a-decimal"/>`)
722722
if err := evt.Validate(); err == nil {
723723
t.Fatal("expected error for invalid height")
724724
}
725725
evt.Detail.Height.Raw = []byte(`<height>1</height>`)
726-
evt.Detail.HeightUnit.Raw = []byte(`<height_unit>x</height_unit>`)
726+
evt.Detail.HeightUnit.Raw = []byte(`<height_unit value="not-an-integer"/>`)
727727
if err := evt.Validate(); err == nil {
728728
t.Fatal("expected error for invalid height_unit")
729729
}
@@ -759,7 +759,7 @@ func TestTAKDetailSchemaValidation(t *testing.T) {
759759
if err := evt.Validate(); err != nil {
760760
t.Fatalf("valid link detail rejected: %v", err)
761761
}
762-
evt.Detail.LinkDetail.Raw = []byte(`<link uid="u"/>`)
762+
evt.Detail.LinkDetail.Raw = []byte(`<link production_time="not-a-datetime"/>`)
763763
if err := evt.Validate(); err == nil {
764764
t.Fatal("expected error for invalid link detail")
765765
}

validator/schema_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,19 @@ func TestValidateRemainingDetailSchemas(t *testing.T) {
279279
name: "color",
280280
schema: "tak-details-color",
281281
good: []byte(`<color argb="1"/>`),
282-
bad: []byte(`<color/>`),
282+
bad: []byte(`<color argb="not-an-integer"/>`),
283283
},
284284
{
285285
name: "height",
286286
schema: "tak-details-height",
287287
good: []byte(`<height>1</height>`),
288-
bad: []byte(`<height>bad</height>`),
288+
bad: []byte(`<height value="not-a-decimal"/>`),
289289
},
290290
{
291291
name: "height_unit",
292292
schema: "tak-details-height_unit",
293293
good: []byte(`<height_unit>1</height_unit>`),
294-
bad: []byte(`<height_unit>x</height_unit>`),
294+
bad: []byte(`<height_unit value="not-an-integer"/>`),
295295
},
296296
{
297297
name: "labels_on",
@@ -303,7 +303,7 @@ func TestValidateRemainingDetailSchemas(t *testing.T) {
303303
name: "link",
304304
schema: "tak-details-link",
305305
good: []byte(`<link uid="u" type="a-f-G" relation="p-p"/>`),
306-
bad: []byte(`<link uid="u"/>`),
306+
bad: []byte(`<link production_time="not-a-datetime"/>`),
307307
},
308308
{
309309
name: "emergency",

0 commit comments

Comments
 (0)