Cleanup record encoding logic, add tests

This commit is contained in:
Tomaž Jerman
2023-03-17 10:58:46 +01:00
parent 1e6cbf6123
commit a0e25b457f
18 changed files with 621 additions and 87 deletions
+11
View File
@@ -312,6 +312,17 @@ func (g DepGraph) ChildrenForResourceType(n *Node, rt string) (out NodeSet) {
return
}
func (g DepGraph) NodeForRef(ref Ref) (out *Node) {
aux := make([]*Node, 0, 10)
for _, sg := range g.graphs {
for _, n := range sg.nodes {
aux = append(aux, n.Node)
}
}
return NodeForRef(ref, aux...)
}
// Children returns all child nodes of n
func (g DepGraph) Children(n *Node) (out NodeSet) {
for _, sg := range g.graphs {
+4
View File
@@ -30,6 +30,9 @@ type (
// Children returns all of the children of the provided node
Children(*Node) NodeSet
// NodeForRef returns the node which matches the provided ref
NodeForRef(Ref) *Node
}
Preparer interface {
@@ -77,6 +80,7 @@ type (
Encoder EncoderConfig
}
EncoderConfig struct {
DefaultUserID uint64
PreferredTimeLayout string
PreferredTimezone string
}