33 lines
636 B
Go
33 lines
636 B
Go
package nodes
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestNodeIsRoot(t *testing.T) {
|
|
n := &Node{ID: "1", ParentID: nil}
|
|
if !n.IsRoot() {
|
|
t.Error("expected node with nil parent to be root")
|
|
}
|
|
|
|
pid := "parent"
|
|
n2 := &Node{ID: "2", ParentID: &pid}
|
|
if n2.IsRoot() {
|
|
t.Error("expected node with parent to not be root")
|
|
}
|
|
}
|
|
|
|
func TestNodeIsDeleted(t *testing.T) {
|
|
n := &Node{ID: "1", DeletedAt: nil}
|
|
if n.IsDeleted() {
|
|
t.Error("expected node with nil DeletedAt to not be deleted")
|
|
}
|
|
|
|
now := time.Now()
|
|
n2 := &Node{ID: "2", DeletedAt: &now}
|
|
if !n2.IsDeleted() {
|
|
t.Error("expected node with DeletedAt set to be deleted")
|
|
}
|
|
}
|