diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-08-30 01:39:24 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-08-30 21:29:44 -0600 |
commit | a371ae78e5280f0a2075692dbb2cfeed4c39bddb (patch) | |
tree | d4edff9cb0c3089d5ed22d98517fac20b9a71c63 /lib/btrfsprogs/btrfsinspect/rebuildnodes/s3_reinit_test.go | |
parent | 9a3006e0de95aba2c5c5509fac7d7a2a24943d4a (diff) |
misc fix
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/s3_reinit_test.go')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/s3_reinit_test.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s3_reinit_test.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s3_reinit_test.go new file mode 100644 index 0000000..b361606 --- /dev/null +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s3_reinit_test.go @@ -0,0 +1,80 @@ +// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com> +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package rebuildnodes_test + +import ( + "strings" + "testing" + + "git.lukeshu.com/go/lowmemjson" + "github.com/stretchr/testify/assert" + + "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" + "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect/rebuildnodes" + "git.lukeshu.com/btrfs-progs-ng/lib/containers" +) + +func TestEncodeRebuiltNodes(t *testing.T) { + dat := map[btrfsvol.LogicalAddr]*rebuildnodes.RebuiltNode{ + 100007133184: { + Errs: containers.Set[string]{ + "btrfs.ReadNode: node@0x0000001748e3c000: expected generation\u003c=6596014 but claims to be generation=6596025": struct{}{}, + }, + MinKey: btrfsprim.Key{}, + MaxKey: btrfsprim.Key{}, + InTrees: containers.Set[btrfsprim.ObjID]{ + 257: struct{}{}, + }, + Node: btrfstree.Node{}, + }, + } + var buf strings.Builder + assert.NoError(t, lowmemjson.Encode(&lowmemjson.ReEncoder{ + Out: &buf, + + Indent: "\t", + ForceTrailingNewlines: true, + }, dat)) + assert.Equal(t, `{ + "100007133184": { + "Errs": [ + "btrfs.ReadNode: node@0x0000001748e3c000: expected generation\u003c=6596014 but claims to be generation=6596025" + ], + "MinKey": { + "ObjectID": 0, + "ItemType": 0, + "Offset": 0 + }, + "MaxKey": { + "ObjectID": 0, + "ItemType": 0, + "Offset": 0 + }, + "InTrees": [ + 257 + ], + "Size": 0, + "ChecksumType": 0, + "Head": { + "Checksum": "0000000000000000000000000000000000000000000000000000000000000000", + "MetadataUUID": "00000000-0000-0000-0000-000000000000", + "Addr": 0, + "Flags": 0, + "BackrefRev": 0, + "ChunkTreeUUID": "00000000-0000-0000-0000-000000000000", + "Generation": 0, + "Owner": 0, + "NumItems": 0, + "Level": 0 + }, + "BodyInternal": null, + "BodyLeaf": null, + "Padding": null + } +} +`, buf.String()) +} |