summaryrefslogtreecommitdiff
path: root/lib/btrfsutil/rebuilt_forrest_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-17 15:53:20 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-17 19:52:26 -0600
commit2fec63f72ded515dd51b08245f344385adbe34fb (patch)
treec8567086086d2190cf8cb95257933a02940426b1 /lib/btrfsutil/rebuilt_forrest_test.go
parenta74c2cd52a12614565349577b8a5a6fbdcf337c3 (diff)
btrfsutil: RebuiltForrest: Have LookupUUID return an error
Diffstat (limited to 'lib/btrfsutil/rebuilt_forrest_test.go')
-rw-r--r--lib/btrfsutil/rebuilt_forrest_test.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/btrfsutil/rebuilt_forrest_test.go b/lib/btrfsutil/rebuilt_forrest_test.go
index 8bbb50a..ef0ed72 100644
--- a/lib/btrfsutil/rebuilt_forrest_test.go
+++ b/lib/btrfsutil/rebuilt_forrest_test.go
@@ -13,6 +13,7 @@ import (
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim"
+ "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfstree"
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol"
)
@@ -20,7 +21,7 @@ type rebuiltForrestCallbacks struct {
addedItem func(ctx context.Context, tree btrfsprim.ObjID, key btrfsprim.Key)
addedRoot func(ctx context.Context, tree btrfsprim.ObjID, root btrfsvol.LogicalAddr)
lookupRoot func(ctx context.Context, tree btrfsprim.ObjID) (offset btrfsprim.Generation, item btrfsitem.Root, ok bool)
- lookupUUID func(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, ok bool)
+ lookupUUID func(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, err error)
}
func (cbs rebuiltForrestCallbacks) AddedItem(ctx context.Context, tree btrfsprim.ObjID, key btrfsprim.Key) {
@@ -35,7 +36,7 @@ func (cbs rebuiltForrestCallbacks) LookupRoot(ctx context.Context, tree btrfspri
return cbs.lookupRoot(ctx, tree)
}
-func (cbs rebuiltForrestCallbacks) LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, ok bool) {
+func (cbs rebuiltForrestCallbacks) LookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, err error) {
return cbs.lookupUUID(ctx, uuid)
}
@@ -96,13 +97,13 @@ func TestRebuiltTreeCycles(t *testing.T) {
}
return 0, btrfsitem.Root{}, false
},
- lookupUUID: func(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, ok bool) {
+ lookupUUID: func(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, err error) {
for _, root := range roots {
if root.UUID == uuid {
- return root.ID, true
+ return root.ID, nil
}
}
- return 0, false
+ return 0, btrfstree.ErrNoItem
},
}
@@ -209,13 +210,13 @@ func TestRebuiltTreeParentErr(t *testing.T) {
}
return 0, btrfsitem.Root{}, false
},
- lookupUUID: func(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, ok bool) {
+ lookupUUID: func(ctx context.Context, uuid btrfsprim.UUID) (id btrfsprim.ObjID, err error) {
for _, root := range roots {
if root.UUID == uuid {
- return root.ID, true
+ return root.ID, nil
}
}
- return 0, false
+ return 0, btrfstree.ErrNoItem
},
}