20318: Comment about error handling.
[arvados.git] / sdk / go / arvados / collection_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import (
8         check "gopkg.in/check.v1"
9 )
10
11 var _ = check.Suite(&CollectionSuite{})
12
13 type CollectionSuite struct{}
14
15 func (s *CollectionSuite) TestSizedDigests(c *check.C) {
16         coll := Collection{ManifestText: ". d41d8cd98f00b204e9800998ecf8427e+0 acbd18db4cc2f85cedef654fccc4a4d8+3 73feffa4b7f6bb68e44cf984c85f6e88+3+Z+K@xyzzy 0:0:foo 0:3:bar 3:3:baz\n"}
17         sd, err := coll.SizedDigests()
18         c.Check(err, check.IsNil)
19         c.Check(sd, check.DeepEquals, []SizedDigest{"acbd18db4cc2f85cedef654fccc4a4d8+3", "73feffa4b7f6bb68e44cf984c85f6e88+3"})
20
21         coll = Collection{ManifestText: ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:foo\n. acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:bar\n. 73feffa4b7f6bb68e44cf984c85f6e88+3+Z+K@xyzzy 0:3:baz\n"}
22         sd, err = coll.SizedDigests()
23         c.Check(err, check.IsNil)
24         c.Check(sd, check.DeepEquals, []SizedDigest{"acbd18db4cc2f85cedef654fccc4a4d8+3", "73feffa4b7f6bb68e44cf984c85f6e88+3"})
25
26         coll = Collection{ManifestText: ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:foo\n"}
27         sd, err = coll.SizedDigests()
28         c.Check(err, check.IsNil)
29         c.Check(sd, check.HasLen, 0)
30
31         coll = Collection{ManifestText: "", PortableDataHash: "d41d8cd98f00b204e9800998ecf8427e+0"}
32         sd, err = coll.SizedDigests()
33         c.Check(err, check.IsNil)
34         c.Check(sd, check.HasLen, 0)
35 }