Ejemplo n.º 1
0
func TestSaveSingleDirectory(t *testing.T) {
	genericDbTest(t, func() {
		dir := new(myfs.Directory)
		dir.InitDirectory("dirname", os.ModeDir|0755, nil)
		dir.SetDirty(true)
		fsdb.PutDirectory(dir)
		anotherDir, _ := fsdb.GetDirectory(dir.Vid)
		assertWithMsg(t, dir.Vid == anotherDir.Vid,
			"Expected Vid to be the same after load.")
		assertWithMsg(t, dir.Name == anotherDir.Name,
			"Expected Name to be the same after load.")
	})
}
Ejemplo n.º 2
0
func TestSaveRoot(t *testing.T) {
	genericDbTest(t, func() {
		dir := new(myfs.Directory)
		dir.InitDirectory("", 0755, nil)
		subdir := new(myfs.Directory)
		subdir.InitDirectory("name", 0755, dir)
		dir.Mkdir(&fuse.MkdirRequest{
			Name: "name",
			Mode: 0755,
		}, nil)
		fsdb.SetRoot(dir)
		fromDb, _ := fsdb.GetRoot()
		assertWithMsg(t, len(dir.ChildVids) == len(fromDb.ChildVids),
			"Expected same number of ChildVids after load.")
	})
}