Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1567)

Delta Between Two Patch Sets: state/charm_test.go

Issue 99640044: Actions() added to Charm interface
Left Patch Set: Created 10 years, 10 months ago
Right Patch Set: Actions() added to Charm interface Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « state/charm.go ('k') | state/conn_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package state_test 4 package state_test
5 5
6 import ( 6 import (
7 "bytes" 7 "bytes"
8 "net/url" 8 "net/url"
9 9
10 "github.com/juju/errors" 10 "github.com/juju/errors"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 meta := dummy.Meta() 42 meta := dummy.Meta()
43 c.Assert(meta.Name, gc.Equals, "dummy") 43 c.Assert(meta.Name, gc.Equals, "dummy")
44 config := dummy.Config() 44 config := dummy.Config()
45 c.Assert(config.Options["title"], gc.Equals, 45 c.Assert(config.Options["title"], gc.Equals,
46 charm.Option{ 46 charm.Option{
47 Default: "My Title", 47 Default: "My Title",
48 Description: "A descriptive title used for the service." , 48 Description: "A descriptive title used for the service." ,
49 Type: "string", 49 Type: "string",
50 }, 50 },
51 ) 51 )
52 actions := dummy.Actions()
53 c.Assert(actions, gc.NotNil)
54 //c.Assert(actions.ActionSpecs, gc.Not(gc.HasLen), 0)
55 //c.Assert(actions.ActionSpecs["snapshot"], gc.NotNil)
56 //c.Assert(actions.ActionSpecs["snapshot"].Params, gc.Not(gc.HasLen), 0)
57 //testActionSpecParams := actions.ActionSpecs["snapshot"].Params.(map[st ring]interface{})
58 c.Assert(actions.ActionSpecs["snapshot"], gc.DeepEquals,
59 charm.ActionSpec{
60 Description: "Take a snapshot of the database.",
61 Params: map[string]interface{}{
62 "outfile": map[string]interface{}{
63 "description": "The file to write out to .",
64 "type": "string",
65 "default": "foo.bz2",
66 },
67 },
68 })
52 } 69 }
53 70
54 func (s *CharmSuite) TestCharmNotFound(c *gc.C) { 71 func (s *CharmSuite) TestCharmNotFound(c *gc.C) {
55 curl := charm.MustParseURL("local:anotherseries/dummy-1") 72 curl := charm.MustParseURL("local:anotherseries/dummy-1")
56 _, err := s.State.Charm(curl) 73 _, err := s.State.Charm(curl)
57 c.Assert(err, gc.ErrorMatches, `charm "local:anotherseries/dummy-1" not found`) 74 c.Assert(err, gc.ErrorMatches, `charm "local:anotherseries/dummy-1" not found`)
58 c.Assert(err, jc.Satisfies, errors.IsNotFound) 75 c.Assert(err, jc.Satisfies, errors.IsNotFound)
59 } 76 }
60 77
61 type CharmTestHelperSuite struct { 78 type CharmTestHelperSuite struct {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 138
122 forEachStandardCharm(c, func(name string) { 139 forEachStandardCharm(c, func(name string) {
123 chd := testing.Charms.Dir(name) 140 chd := testing.Charms.Dir(name)
124 meta := chd.Meta() 141 meta := chd.Meta()
125 142
126 ch := s.AddConfigCharm(c, name, configYaml, 123) 143 ch := s.AddConfigCharm(c, name, configYaml, 123)
127 assertCustomCharm(c, ch, "quantal", meta, config, 123) 144 assertCustomCharm(c, ch, "quantal", meta, config, 123)
128 }) 145 })
129 } 146 }
130 147
148 var actionsYaml = `
149 actions:
150 dump:
151 description: Dump the database to STDOUT.
152 params:
153 redirect-file:
154 description: Redirect to a log file.
155 type: string
156 `
157
158 func (s *CharmTestHelperSuite) TestActionsCharm(c *gc.C) {
159 actions, err := charm.ReadActionsYaml(bytes.NewBuffer([]byte(actionsYaml )))
160 c.Assert(err, gc.IsNil)
161
162 forEachStandardCharm(c, func(name string) {
163 // chd := testing.Charms.Dir(name)
164
165 ch := s.AddActionsCharm(c, name, actionsYaml, 123)
166 c.Assert(ch.Actions(), gc.DeepEquals, actions)
167 })
168 }
169
131 var metaYamlSnippet = ` 170 var metaYamlSnippet = `
132 summary: blah 171 summary: blah
133 description: blah blah 172 description: blah blah
134 ` 173 `
135 174
136 func (s *CharmTestHelperSuite) TestMetaCharm(c *gc.C) { 175 func (s *CharmTestHelperSuite) TestMetaCharm(c *gc.C) {
137 forEachStandardCharm(c, func(name string) { 176 forEachStandardCharm(c, func(name string) {
138 chd := testing.Charms.Dir(name) 177 chd := testing.Charms.Dir(name)
139 config := chd.Config() 178 config := chd.Config()
140 metaYaml := "name: " + name + metaYamlSnippet 179 metaYaml := "name: " + name + metaYamlSnippet
141 meta, err := charm.ReadMeta(bytes.NewBuffer([]byte(metaYaml))) 180 meta, err := charm.ReadMeta(bytes.NewBuffer([]byte(metaYaml)))
142 c.Assert(err, gc.IsNil) 181 c.Assert(err, gc.IsNil)
143 182
144 ch := s.AddMetaCharm(c, name, metaYaml, 123) 183 ch := s.AddMetaCharm(c, name, metaYaml, 123)
145 assertCustomCharm(c, ch, "quantal", meta, config, 123) 184 assertCustomCharm(c, ch, "quantal", meta, config, 123)
146 }) 185 })
147 } 186 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b