mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(hierarchy): descPrefix selector for Compose testTag + UUID suffixes
This commit is contained in:
1 parent
fb6c3ca517
commit
eea9a0067a
2 files changed
+16
No files matched your search
@@ -6,6 +6,7 @@
|
|||||||
// id:<suffix> — match resource-id ending with ":id/<suffix>" or equal to <suffix>
|
// id:<suffix> — match resource-id ending with ":id/<suffix>" or equal to <suffix>
|
||||||
// text:<value> — exact match on the node's text
|
// text:<value> — exact match on the node's text
|
||||||
// desc:<value> — exact match on the node's content-desc
|
// desc:<value> — exact match on the node's content-desc
|
||||||
|
// descPrefix:<prefix> — startsWith match on the node's content-desc (e.g. Compose testTag + UUID)
|
||||||
package hierarchy
|
package hierarchy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -133,6 +134,8 @@ func match(element *Element, kind, value string) bool {
|
|||||||
return element.Text == value
|
return element.Text == value
|
||||||
case "desc":
|
case "desc":
|
||||||
return element.Description == value
|
return element.Description == value
|
||||||
|
case "descPrefix":
|
||||||
|
return strings.HasPrefix(element.Description, value)
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,3 +73,16 @@ func TestUnknownSelector(t *testing.T) {
|
|||||||
t.Fatal("unknown kind should not match")
|
t.Fatal("unknown kind should not match")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDescPrefix(t *testing.T) {
|
||||||
|
xml := `<hierarchy>
|
||||||
|
<node content-desc="customer_row_abc-123" bounds="[0,0][100,100]"/>
|
||||||
|
<node content-desc="customer_row_def-456" bounds="[0,100][100,200]"/>
|
||||||
|
<node content-desc="supplier_row_xyz" bounds="[0,200][100,300]"/>
|
||||||
|
</hierarchy>`
|
||||||
|
tree, _ := Parse(xml)
|
||||||
|
rows := tree.FindAll("descPrefix:customer_row_")
|
||||||
|
if len(rows) != 2 {
|
||||||
|
t.Fatalf("want 2 customer rows, got %d", len(rows))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user