integration/sharing: test that we also camget the dir contents

Change-Id: Ib45e520405403964b9b3480f62493efe9e6e1b17
This commit is contained in:
mpl 2014-08-19 22:05:38 +02:00
parent ae097a3960
commit bee3fa97c2
1 changed files with 18 additions and 1 deletions

View File

@ -51,9 +51,26 @@ func share(t *testing.T, file string) {
// test that we can get it through the share
test.MustRunCmd(t, w.Cmd("camget", "-o", testDir, "-shared", fmt.Sprintf("%v/share/%v", w.ServerBaseURL(), shareRef)))
if _, err := os.Stat(filepath.Join(testDir, filepath.Base(file))); err != nil {
filePath := filepath.Join(testDir, filepath.Base(file))
fi, err := os.Stat(filePath)
if err != nil {
t.Fatalf("camget -shared failed to get %v: %v", file, err)
}
if fi.IsDir() {
// test that we also get the dir contents
d, err := os.Open(filePath)
if err != nil {
t.Fatal(err)
}
defer d.Close()
names, err := d.Readdirnames(-1)
if err != nil {
t.Fatal(err)
}
if len(names) == 0 {
t.Fatalf("camget did not fetch contents of directory %v", file)
}
}
// test that we're not allowed to get it directly
fileURL := fmt.Sprintf("%v/share/%v", w.ServerBaseURL(), fileRef)