func opClientServiceSetCharm(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceSetCharm("nosuch", "local:series/wordpress", false) if params.ErrCode(err) == params.CodeNotFound { err = nil } return func() {}, err }
func opClientAddServiceUnits(c *C, st *api.State, mst *state.State) (func(), error) { _, err := st.Client().AddServiceUnits("nosuch", 1) if params.ErrCode(err) == params.CodeNotFound { err = nil } return func() {}, err }
func opClientServiceUnexpose(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceUnexpose("wordpress") if err != nil { return func() {}, err } return func() {}, nil }
func opClientDestroyServiceUnits(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().DestroyServiceUnits([]string{"wordpress/99"}) if err != nil && strings.HasPrefix(err.Error(), "no units were destroyed") { err = nil } return func() {}, err }
func opClientServiceSetYAML(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceSetYAML("wordpress", `"wordpress": {"blog-title": "foo"}`) if err != nil { return func() {}, err } return resetBlogTitle(c, st), nil }
func opClientServiceDestroy(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceDestroy("non-existent") if params.ErrCode(err) == params.CodeNotFound { err = nil } return func() {}, err }
func opClientDestroyRelation(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().DestroyRelation("nosuch1", "nosuch2") if params.ErrCode(err) == params.CodeNotFound { err = nil } return func() {}, err }
func opClientServiceDeploy(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceDeploy("mad:bad/url-1", "x", 1, "", constraints.Value{}) if err.Error() == `charm URL has invalid schema: "mad:bad/url-1"` { err = nil } return func() {}, err }
func opClientWatchAll(c *C, st *api.State, mst *state.State) (func(), error) { watcher, err := st.Client().WatchAll() if err == nil { watcher.Stop() } return func() {}, err }
func resetBlogTitle(c *C, st *api.State) func() { return func() { err := st.Client().ServiceSet("wordpress", map[string]string{ "blog-title": "", }) c.Assert(err, IsNil) } }
func opClientGetAnnotations(c *C, st *api.State, mst *state.State) (func(), error) { ann, err := st.Client().GetAnnotations("service-wordpress") if err != nil { return func() {}, err } c.Assert(ann, DeepEquals, make(map[string]string)) return func() {}, nil }
func opClientSetServiceConstraints(c *C, st *api.State, mst *state.State) (func(), error) { nullConstraints := constraints.Value{} err := st.Client().SetServiceConstraints("wordpress", nullConstraints) if err != nil { return func() {}, err } return func() {}, nil }
func opClientStatus(c *C, st *api.State, mst *state.State) (func(), error) { status, err := st.Client().Status() if err != nil { c.Check(status, IsNil) return func() {}, err } c.Assert(status, DeepEquals, scenarioStatus) return func() {}, nil }
func opClientServiceSet(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceSet("wordpress", map[string]string{ "blog-title": "foo", }) if err != nil { return func() {}, err } return resetBlogTitle(c, st), nil }
func opClientServiceExpose(c *C, st *api.State, mst *state.State) (func(), error) { err := st.Client().ServiceExpose("wordpress") if err != nil { return func() {}, err } return func() { svc, err := mst.Service("wordpress") c.Assert(err, IsNil) svc.ClearExposed() }, nil }
func opClientCharmInfo(c *C, st *api.State, mst *state.State) (func(), error) { info, err := st.Client().CharmInfo("local:series/wordpress-3") if err != nil { c.Check(info, IsNil) return func() {}, err } c.Assert(info.URL, Equals, "local:series/wordpress-3") c.Assert(info.Meta.Name, Equals, "wordpress") c.Assert(info.Revision, Equals, 3) return func() {}, nil }
func opClientSetAnnotations(c *C, st *api.State, mst *state.State) (func(), error) { pairs := map[string]string{"key1": "value1", "key2": "value2"} err := st.Client().SetAnnotations("service-wordpress", pairs) if err != nil { return func() {}, err } return func() { pairs := map[string]string{"key1": "", "key2": ""} st.Client().SetAnnotations("service-wordpress", pairs) }, nil }
func opClientServiceUpdate(c *C, st *api.State, mst *state.State) (func(), error) { args := params.ServiceUpdate{ ServiceName: "no-such-charm", CharmUrl: "cs:series/wordpress-42", ForceCharmUrl: true, SettingsStrings: map[string]string{"blog-title": "foo"}, SettingsYAML: `"wordpress": {"blog-title": "foo"}`, } err := st.Client().ServiceUpdate(args) if params.ErrCode(err) == params.CodeNotFound { err = nil } return func() {}, err }
func opClientResolved(c *C, st *api.State, _ *state.State) (func(), error) { err := st.Client().Resolved("wordpress/0", false) // There are several scenarios in which this test is called, one is // that the user is not authorized. In that case we want to exit now, // letting the error percolate out so the caller knows that the // permission error was correctly generated. if err != nil && params.ErrCode(err) == params.CodeUnauthorized { return func() {}, err } // Otherwise, the user was authorized, but we expect an error anyway // because the unit is not in an error state when we tried to resolve // the error. Therefore, since it is complaining it means that the // call to Resolved worked, so we're happy. c.Assert(err, NotNil) c.Assert(err.Error(), Equals, `unit "wordpress/0" is not in an error state`) return func() {}, nil }
func opClientGetServiceConstraints(c *C, st *api.State, mst *state.State) (func(), error) { _, err := st.Client().GetServiceConstraints("wordpress") return func() {}, err }