12308: Check contents of test mount.
authorTom Clegg <tom@tomclegg.ca>
Tue, 4 Feb 2020 14:45:18 +0000 (09:45 -0500)
committerTom Clegg <tom@tomclegg.ca>
Tue, 4 Feb 2020 14:45:18 +0000 (09:45 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/mount/command_test.go

index 9cd413979f7a708577e4fca6eb293f061a98ab3d..d222e8ccbfef28d782e754670bfe13c97c74f9a8 100644 (file)
@@ -6,10 +6,12 @@ package mount
 
 import (
        "bytes"
+       "encoding/json"
        "io/ioutil"
        "os"
        "time"
 
+       "git.arvados.org/arvados.git/sdk/go/arvadostest"
        check "gopkg.in/check.v1"
 )
 
@@ -42,6 +44,26 @@ func (s *CmdSuite) TestMount(c *check.C) {
        go func() {
                <-mountCmd.ready
                ready = true
+
+               f, err := os.Open(s.mnt + "/by_id/" + arvadostest.FooCollection)
+               if c.Check(err, check.IsNil) {
+                       dirnames, err := f.Readdirnames(-1)
+                       c.Check(err, check.IsNil)
+                       c.Check(dirnames, check.DeepEquals, []string{"foo"})
+                       f.Close()
+               }
+
+               buf, err := ioutil.ReadFile(s.mnt + "/by_id/" + arvadostest.FooCollection + "/.arvados#collection")
+               if c.Check(err, check.IsNil) {
+                       var m map[string]interface{}
+                       err = json.Unmarshal(buf, &m)
+                       c.Check(err, check.NotNil)
+                       c.Check(m["manifest_text"], check.Matches, `\. acbd.* 0:3:foo\n`)
+               }
+
+               _, err = os.Open(s.mnt + "/by_id/zzzzz-4zz18-does-not-exist")
+               c.Check(os.IsNotExist(err), check.Equals, true)
+
                ok := mountCmd.Unmount()
                c.Check(ok, check.Equals, true)
        }()