fix GetRandomNode
This commit is contained in:
parent
c96da91077
commit
ecfd279d7e
3 changed files with 6 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
v1.0.7, released 2025-03-16
|
||||||
|
* bugfixes
|
||||||
|
- GetRandomNode public command
|
||||||
|
|
||||||
v1.0.6, released 2025-03-16
|
v1.0.6, released 2025-03-16
|
||||||
* features
|
* features
|
||||||
- Node.Get - get object property value
|
- Node.Get - get object property value
|
||||||
|
|
|
@ -338,7 +338,7 @@ func (db *DB) Length(vpath string) (int64, error) {
|
||||||
return int64(len(node.Nodes)), nil
|
return int64(len(node.Nodes)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) getRandomNode(vpath string) (Node, error) {
|
func (db *DB) GetRandomNode(vpath string) (Node, error) {
|
||||||
node, found := db.GetNode(vpath)
|
node, found := db.GetNode(vpath)
|
||||||
if !found {
|
if !found {
|
||||||
return Node{}, fmt.Errorf("Node not found")
|
return Node{}, fmt.Errorf("Node not found")
|
||||||
|
|
|
@ -266,7 +266,7 @@ func TestListRandomNode(t *testing.T) {
|
||||||
node, _ := db.GetNode("object.list3")
|
node, _ := db.GetNode("object.list3")
|
||||||
node.FixType()
|
node.FixType()
|
||||||
|
|
||||||
node, _ = db.getRandomNode("object.list3")
|
node, _ = db.GetRandomNode("object.list3")
|
||||||
if node.Nodes["key"].Value != "value" {
|
if node.Nodes["key"].Value != "value" {
|
||||||
fmt.Println(node)
|
fmt.Println(node)
|
||||||
t.Fatal("Random node value wrong")
|
t.Fatal("Random node value wrong")
|
||||||
|
|
Loading…
Add table
Reference in a new issue