Esempio n. 1
0
func TestCreateMappingOneDeepCheckName(t *testing.T) {
	filepairs := CreateFilePairsMock()
	filepairsMap := focusfs.CreateMapping(filepairs, 2)
	for key := range filepairsMap {
		for _, filepair := range filepairsMap[key] {
			if strings.Index(filepair.Newname, _TestGetId(key, filepair)) != 0 {
				t.Errorf("Expected name of %s, found %s: [%s] %s",
					_TestGetId(key, filepair), filepair.Newname, key, filepair)
			}
		}
	}
}
Esempio n. 2
0
func TestCreateMappingThreeDeepCheckSize(t *testing.T) {
	filepairs := CreateFilePairsMock()
	filepairsMap := focusfs.CreateMapping(filepairs, 3)
	shouldBeLen10Slice := []string{"", "bar", "foo", "bar/baz/bam", "foo/bar", "foo/bar/baz"}
	for _, shouldBeLen10 := range shouldBeLen10Slice {
		if len(filepairsMap[shouldBeLen10]) != 10 {
			t.Errorf("Dir %s should contain 10 files, had %d: %s",
				shouldBeLen10, len(filepairsMap[shouldBeLen10]),
				filepairsMap[shouldBeLen10])
		}
	}
}
Esempio n. 3
0
func TestCreateMappingFlatCheckSize(t *testing.T) {
	filepairs := CreateFilePairsMock()
	filepairsMap := focusfs.CreateMapping(filepairs, 0)
	if len(filepairsMap) != 1 {
		t.Errorf("There should only be one key, found %d", len(filepairsMap))
	}
	if len(filepairsMap[""]) != 60 {
		t.Errorf("Dir should contain 60 files, had %d: %s",
			len(filepairsMap[""]),
			filepairsMap[""])
	}
}
Esempio n. 4
0
func _TestCreateMappingNoNesting(t *testing.T, depth int) {
	filepairs := CreateFilePairsMock()
	filepairsMap := focusfs.CreateMapping(filepairs, depth)
	shouldBeLen10Slice := []string{"", "bar", "foo", "bar/baz/bam", "foo/bar", "foo/bar/baz/bam/boo"}
	for _, shouldBeLen10 := range shouldBeLen10Slice {
		if len(filepairsMap[shouldBeLen10]) != 10 {
			t.Errorf("Depth: %d, Dir %s should contain 10 files, had %d: %s",
				depth, shouldBeLen10, len(filepairsMap[shouldBeLen10]),
				filepairsMap[shouldBeLen10])
		}
	}
	shouldBeEmptySlice := []string{"bar/baz", "foo/bar/baz", "foo/bar/baz/bam"}
	for _, shouldBeEmpty := range shouldBeEmptySlice {
		if len(filepairsMap[shouldBeEmpty]) != 0 {
			t.Errorf("Depth: %d, Dir %s should be empty, had: %d: %s",
				depth, shouldBeEmpty, len(filepairsMap[shouldBeEmpty]),
				filepairsMap[shouldBeEmpty])
		}
	}
}
Esempio n. 5
0
func main() {
	flag.Parse()
	if len(flag.Args()) < 1 {
		log.Fatal("Usage:\n  hello MOUNTPOINT")
	}

	osD := &focusfs.OsDeploy{}
	exifD := &focusfs.ExifDeploy{}
	pairs := focusfs.FindFilenames(&focusfs.FilepathDeploy{}, "/home/jmann/AeroFS/ph2/")
	sort.Sort(pairs)
	pairs = focusfs.SetNecessaryExifData(osD, exifD, pairs)
	filepairs = focusfs.CreateMapping(pairs, 0)
	fmt.Println(filepairs)
	for k := range filepairs {
		dirs = append(dirs, k)
	}

	nfs := pathfs.NewPathNodeFs(&FocusFs{FileSystem: pathfs.NewDefaultFileSystem()}, nil)
	server, _, err := nodefs.MountRoot(flag.Arg(0), nfs.Root(), nil)
	if err != nil {
		log.Fatalf("Mount fail: %v\n", err)
	}
	server.Serve()
}