aboutsummaryrefslogtreecommitdiffstats
path: root/formats/packp/capabilities_test.go
blob: e42a0c7c17b24dc8675e86d797ffdac43e8afd39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package packp

import (
	"testing"

	. "gopkg.in/check.v1"
)

func Test(t *testing.T) { TestingT(t) }

type SuiteCapabilities struct{}

var _ = Suite(&SuiteCapabilities{})

func (s *SuiteCapabilities) TestDecode(c *C) {
	cap := NewCapabilities()
	cap.Decode("symref=foo symref=qux thin-pack")

	c.Assert(cap.m, HasLen, 2)
	c.Assert(cap.Get("symref").Values, DeepEquals, []string{"foo", "qux"})
	c.Assert(cap.Get("thin-pack").Values, DeepEquals, []string{""})
}

func (s *SuiteCapabilities) TestSet(c *C) {
	cap := NewCapabilities()
	cap.Add("symref", "foo", "qux")
	cap.Set("symref", "bar")

	c.Assert(cap.m, HasLen, 1)
	c.Assert(cap.Get("symref").Values, DeepEquals, []string{"bar"})
}

func (s *SuiteCapabilities) TestSetEmpty(c *C) {
	cap := NewCapabilities()
	cap.Set("foo", "bar")

	c.Assert(cap.Get("foo").Values, HasLen, 1)
}

func (s *SuiteCapabilities) TestAdd(c *C) {
	cap := NewCapabilities()
	cap.Add("symref", "foo", "qux")
	cap.Add("thin-pack")

	c.Assert(cap.String(), Equals, "symref=foo symref=qux thin-pack")
}