-
Notifications
You must be signed in to change notification settings - Fork 59
/
manifest_test.go
64 lines (56 loc) · 1.29 KB
/
manifest_test.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2021 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package charm
import (
"strings"
"github.com/juju/testing"
gc "gopkg.in/check.v1"
)
type manifestSuite struct {
testing.CleanupSuite
}
var _ = gc.Suite(&manifestSuite{})
func (s *manifestSuite) TestReadManifest(c *gc.C) {
manifest, err := ReadManifest(strings.NewReader(`
bases:
- name: ubuntu
channel: "18.04"
architectures: ["amd64","aarch64","s390x"]
- name: ubuntu
channel: "20.04/stable"
`))
c.Assert(err, gc.IsNil)
c.Assert(manifest, gc.DeepEquals, &Manifest{Bases: []Base{{
Name: "ubuntu",
Channel: Channel{
Track: "18.04",
Risk: "stable",
Branch: "",
},
Architectures: []string{"amd64", "arm64", "s390x"},
}, {
Name: "ubuntu",
Channel: Channel{
Track: "20.04",
Risk: "stable",
Branch: "",
},
},
}})
}
func (s *manifestSuite) TestReadValidateManifest(c *gc.C) {
_, err := ReadManifest(strings.NewReader(`
bases:
- name: ""
channel: "18.04"
`))
c.Assert(err, gc.ErrorMatches, "manifest: base without name not valid")
}
func (s *manifestSuite) TestValidateManifest(c *gc.C) {
manifest := &Manifest{
Bases: []Base{{
Name: "",
}},
}
c.Assert(manifest.Validate(), gc.ErrorMatches, "validating manifest: base without name not valid")
}