9397: Update comment & tests for CollectionFileReader to reflect it is more
authorPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 10 Feb 2017 16:02:33 +0000 (11:02 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 10 Feb 2017 16:02:33 +0000 (11:02 -0500)
lenient in the paths it accepts as a result of updates to implementation of
manifest.FileSegmentIterByName.

sdk/go/keepclient/collectionreader.go
sdk/go/keepclient/collectionreader_test.go

index 61fabefacdd5ee937faab81c792370bd8af2c675..344a70c50bf09798e27bb41187fbdcb4d8d35b6e 100644 (file)
@@ -35,9 +35,9 @@ const (
 // parameter when retrieving the collection record).
 var ErrNoManifest = errors.New("Collection has no manifest")
 
-// CollectionFileReader returns a Reader that reads file content from
-// a collection. The filename must be given relative to the root of
-// the collection, without a leading "./".
+// CollectionFileReader returns a Reader that reads content from a single file
+// in the collection. The filename must be relative to the root of the
+// collection.  A leading prefix of "/" or "./" in the filename is ignored.
 func (kc *KeepClient) CollectionFileReader(collection map[string]interface{}, filename string) (Reader, error) {
        mText, ok := collection["manifest_text"].(string)
        if !ok {
index 7b2e94efaa12f435441e9bd36ab120e704cd51b1..6e743f9a9e1a609c90dadbc86b22224ad8d77005 100644 (file)
@@ -102,11 +102,11 @@ func (s *CollectionReaderUnit) TestCollectionReaderContent(c *check.C) {
        for _, testCase := range []rdrTest{
                {mt: mt, f: "zzzz", want: os.ErrNotExist},
                {mt: mt, f: "frob", want: os.ErrNotExist},
-               {mt: mt, f: "/segmented/frob", want: os.ErrNotExist},
-               {mt: mt, f: "./segmented/frob", want: os.ErrNotExist},
-               {mt: mt, f: "/f", want: os.ErrNotExist},
-               {mt: mt, f: "./f", want: os.ErrNotExist},
-               {mt: mt, f: "foo bar//baz", want: os.ErrNotExist},
+               {mt: mt, f: "/segmented/frob", want: "frob"},
+               {mt: mt, f: "./segmented/frob", want: "frob"},
+               {mt: mt, f: "/f", want: "f"},
+               {mt: mt, f: "./f", want: "f"},
+               {mt: mt, f: "foo bar//baz", want: "foo"},
                {mt: mt, f: "foo/zero", want: ""},
                {mt: mt, f: "zero@0", want: ""},
                {mt: mt, f: "zero@1", want: ""},