Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
930e8c98
Commit
930e8c98
authored
May 05, 2021
by
Lucas Molas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
8c3d5ec0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
io/directory_test.go
io/directory_test.go
+24
-0
No files found.
io/directory_test.go
View file @
930e8c98
...
...
@@ -98,6 +98,30 @@ func TestDuplicateAddDir(t *testing.T) {
}
}
func
TestUpgradeableDirectory
(
t
*
testing
.
T
)
{
oldHamtOption
:=
UseHAMTSharding
defer
func
()
{
UseHAMTSharding
=
oldHamtOption
}()
ds
:=
mdtest
.
Mock
()
UseHAMTSharding
=
false
// Create a BasicDirectory.
dir
:=
NewDirectory
(
ds
)
if
_
,
ok
:=
dir
.
(
UpgradeableDirectory
)
.
Directory
.
(
*
BasicDirectory
);
!
ok
{
t
.
Fatal
(
"UpgradeableDirectory doesn't contain BasicDirectory"
)
}
// Any new directory entry will trigger the upgrade to HAMTDirectory
UseHAMTSharding
=
true
err
:=
dir
.
AddChild
(
context
.
Background
(),
"test"
,
ft
.
EmptyDirNode
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
_
,
ok
:=
dir
.
(
UpgradeableDirectory
)
.
Directory
.
(
*
HAMTDirectory
);
!
ok
{
t
.
Fatal
(
"UpgradeableDirectory wasn't upgraded to HAMTDirectory"
)
}
}
func
TestDirBuilder
(
t
*
testing
.
T
)
{
ds
:=
mdtest
.
Mock
()
dir
:=
NewDirectory
(
ds
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment