From bee3fa97c2b2e05ee93129cb59513ce28279c543 Mon Sep 17 00:00:00 2001 From: mpl Date: Tue, 19 Aug 2014 22:05:38 +0200 Subject: [PATCH] integration/sharing: test that we also camget the dir contents Change-Id: Ib45e520405403964b9b3480f62493efe9e6e1b17 --- pkg/test/integration/share_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/test/integration/share_test.go b/pkg/test/integration/share_test.go index 097cd72fd..06c38a660 100644 --- a/pkg/test/integration/share_test.go +++ b/pkg/test/integration/share_test.go @@ -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)