[ARVADOS] updated: cbb83753ad30787399b08989173fad61f0a7374f
git at public.curoverse.com
git at public.curoverse.com
Thu Nov 26 10:42:14 EST 2015
Summary of changes:
sdk/go/manifest/manifest.go | 17 ++++++++++++++---
sdk/go/manifest/manifest_test.go | 14 +++++++++-----
services/datamanager/collection/collection_test.go | 1 -
3 files changed, 23 insertions(+), 9 deletions(-)
via cbb83753ad30787399b08989173fad61f0a7374f (commit)
from 779e41aaaa1f4d3a696a63011c00648bfbfaae72 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cbb83753ad30787399b08989173fad61f0a7374f
Author: radhika <radhika at curoverse.com>
Date: Thu Nov 26 10:33:31 2015 -0500
7253: update manigest.parseManifestStream to raise error when the given manifest does not have any block locators or file tokens.
diff --git a/sdk/go/manifest/manifest.go b/sdk/go/manifest/manifest.go
index 6deb88f..d4b9830 100644
--- a/sdk/go/manifest/manifest.go
+++ b/sdk/go/manifest/manifest.go
@@ -184,10 +184,16 @@ func (s *ManifestStream) sendFileSegmentIterByName(filepath string, ch chan<- *F
func parseManifestStream(s string) (m ManifestStream) {
tokens := strings.Split(s, " ")
+
m.StreamName = UnescapeName(tokens[0])
+ if m.StreamName != "." && !strings.HasPrefix(m.StreamName, "./") {
+ m.Err = fmt.Errorf("Invalid stream name: %s", m.StreamName)
+ return
+ }
+
tokens = tokens[1:]
var i int
- for i = range tokens {
+ for i = 0; i < len(tokens); i++ {
if !blockdigest.IsBlockLocator(tokens[i]) {
break
}
@@ -195,8 +201,13 @@ func parseManifestStream(s string) (m ManifestStream) {
m.Blocks = tokens[:i]
m.FileTokens = tokens[i:]
- if m.StreamName != "." && !strings.HasPrefix(m.StreamName, "./") {
- m.Err = fmt.Errorf("Invalid stream name: %s", m.StreamName)
+ if len(m.Blocks) == 0 {
+ m.Err = fmt.Errorf("No block locators found")
+ return
+ }
+
+ if len(m.FileTokens) == 0 {
+ m.Err = fmt.Errorf("No file tokens found")
return
}
diff --git a/sdk/go/manifest/manifest_test.go b/sdk/go/manifest/manifest_test.go
index 53d4a15..971cd3b 100644
--- a/sdk/go/manifest/manifest_test.go
+++ b/sdk/go/manifest/manifest_test.go
@@ -202,12 +202,16 @@ func TestBlockIterWithBadManifest(t *testing.T) {
{"badstream acbd18db4cc2f85cedef654fccc4a4d8+3 0:1:file1.txt", "Invalid stream name: badstream"},
{"/badstream acbd18db4cc2f85cedef654fccc4a4d8+3 0:1:file1.txt", "Invalid stream name: /badstream"},
{". acbd18db4cc2f85cedef654fccc4a4d8+3 file1.txt", "Invalid file token: file1.txt"},
- {". acbd18db4cc2f85cedef654fccc4a4+3 0:1:file1.txt", "Invalid file token: acbd18db4cc2f85cedef654fccc4a4.*"},
- {". acbd18db4cc2f85cedef654fccc4a4d8 0:1:file1.txt", "Invalid file token: acbd18db4cc2f85cedef654fccc4a4d8"},
+ {". acbd18db4cc2f85cedef654fccc4a4+3 0:1:file1.txt", "No block locators found"},
+ {". acbd18db4cc2f85cedef654fccc4a4d8 0:1:file1.txt", "No block locators found"},
{". acbd18db4cc2f85cedef654fccc4a4d8+3 0:1:file1.txt file2.txt 1:2:file3.txt", "Invalid file token: file2.txt"},
{". acbd18db4cc2f85cedef654fccc4a4d8+3 0:1:file1.txt. bcde18db4cc2f85cedef654fccc4a4d8+3 1:2:file3.txt", "Invalid file token: bcde18db4cc2f85cedef654fccc4a4d8.*"},
{". acbd18db4cc2f85cedef654fccc4a4d8+3 0:1:file1.txt\n. acbd18db4cc2f85cedef654fccc4a4d8+3 ::file2.txt\n", "Invalid file token: ::file2.txt"},
- {". acbd18db4cc2f85cedef654fccc4a4d8+3 bcde18db4cc2f85cedef654fccc4a4d8+3\n", "Invalid file token: bcde18db4cc2f85cedef654fccc4a4d8.*"},
+ {". acbd18db4cc2f85cedef654fccc4a4d8+3 bcde18db4cc2f85cedef654fccc4a4d8+3\n", "No file tokens found"},
+ {". acbd18db4cc2f85cedef654fccc4a4d8+3 ", "Invalid file token"},
+ {". acbd18db4cc2f85cedef654fccc4a4d8+3", "No file tokens found"},
+ {". 0:1:file1.txt\n", "No block locators found"},
+ {".\n", "No block locators found"},
}
for _, testCase := range testCases {
@@ -220,12 +224,12 @@ func TestBlockIterWithBadManifest(t *testing.T) {
// completed reading from blockChannel; now check for errors
if manifest.Err == nil {
- t.Errorf("Expected error")
+ t.Fatalf("Expected error")
}
matched, _ := regexp.MatchString(testCase[1], manifest.Err.Error())
if !matched {
- t.Errorf("Expected error not found. Expected: %v; Found: %v", testCase[1], manifest.Err.Error())
+ t.Fatalf("Expected error not found. Expected: %v; Found: %v", testCase[1], manifest.Err.Error())
}
}
}
diff --git a/services/datamanager/collection/collection_test.go b/services/datamanager/collection/collection_test.go
index 71a4785..22cf54f 100644
--- a/services/datamanager/collection/collection_test.go
+++ b/services/datamanager/collection/collection_test.go
@@ -196,7 +196,6 @@ func testGetCollectionsAndSummarize(c *C, testData APITestData) {
if testData.expectedError == "" {
c.Assert(results.Err, IsNil)
- c.Assert(results, NotNil)
} else {
c.Assert(results.Err, ErrorMatches, testData.expectedError)
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list