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

Side by Side Diff: state/megawatcher_internal_test.go

Issue 12522043: Implemented the ServiceUpdate API call.
Patch Set: Implemented the ServiceUpdate API call. Created 10 years, 7 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:
View unified diff | Download patch
« no previous file with comments | « state/megawatcher.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 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 4 package state
5 5
6 import ( 6 import (
7 "errors" 7 "errors"
8 "fmt" 8 "fmt"
9 "reflect" 9 "reflect"
10 "sort" 10 "sort"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 add(&params.MachineInfo{ 77 add(&params.MachineInfo{
78 Id: "0", 78 Id: "0",
79 InstanceId: "i-machine-0", 79 InstanceId: "i-machine-0",
80 Status: params.StatusPending, 80 Status: params.StatusPending,
81 }) 81 })
82 82
83 wordpress, err := s.State.AddService("wordpress", AddTestingCharm(c, s.S tate, "wordpress")) 83 wordpress, err := s.State.AddService("wordpress", AddTestingCharm(c, s.S tate, "wordpress"))
84 c.Assert(err, IsNil) 84 c.Assert(err, IsNil)
85 err = wordpress.SetExposed() 85 err = wordpress.SetExposed()
86 c.Assert(err, IsNil) 86 c.Assert(err, IsNil)
87 err = wordpress.SetMinUnits(3)
88 c.Assert(err, IsNil)
87 err = wordpress.SetConstraints(constraints.MustParse("mem=100M")) 89 err = wordpress.SetConstraints(constraints.MustParse("mem=100M"))
88 c.Assert(err, IsNil) 90 c.Assert(err, IsNil)
89 setServiceConfigAttr(c, wordpress, "blog-title", "boring") 91 setServiceConfigAttr(c, wordpress, "blog-title", "boring")
90 add(&params.ServiceInfo{ 92 add(&params.ServiceInfo{
91 Name: "wordpress", 93 Name: "wordpress",
92 Exposed: true, 94 Exposed: true,
93 CharmURL: serviceCharmURL(wordpress).String(), 95 CharmURL: serviceCharmURL(wordpress).String(),
94 Life: params.Life(Alive.String()), 96 Life: params.Life(Alive.String()),
97 MinUnits: 3,
95 Constraints: constraints.MustParse("mem=100M"), 98 Constraints: constraints.MustParse("mem=100M"),
96 Config: charm.Settings{"blog-title": "boring"}, 99 Config: charm.Settings{"blog-title": "boring"},
97 }) 100 })
98 pairs := map[string]string{"x": "12", "y": "99"} 101 pairs := map[string]string{"x": "12", "y": "99"}
99 err = wordpress.SetAnnotations(pairs) 102 err = wordpress.SetAnnotations(pairs)
100 c.Assert(err, IsNil) 103 c.Assert(err, IsNil)
101 add(&params.AnnotationInfo{ 104 add(&params.AnnotationInfo{
102 Tag: "service-wordpress", 105 Tag: "service-wordpress",
103 Annotations: pairs, 106 Annotations: pairs,
104 }) 107 })
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 C: "services", 406 C: "services",
404 Id: "wordpress", 407 Id: "wordpress",
405 }, 408 },
406 }, { 409 }, {
407 about: "service is added if it's in backing but not in Store", 410 about: "service is added if it's in backing but not in Store",
408 setUp: func(c *C, st *State) { 411 setUp: func(c *C, st *State) {
409 wordpress, err := st.AddService("wordpress", AddTestingC harm(c, st, "wordpress")) 412 wordpress, err := st.AddService("wordpress", AddTestingC harm(c, st, "wordpress"))
410 c.Assert(err, IsNil) 413 c.Assert(err, IsNil)
411 err = wordpress.SetExposed() 414 err = wordpress.SetExposed()
412 c.Assert(err, IsNil) 415 c.Assert(err, IsNil)
416 err = wordpress.SetMinUnits(42)
417 c.Assert(err, IsNil)
413 }, 418 },
414 change: watcher.Change{ 419 change: watcher.Change{
415 C: "services", 420 C: "services",
416 Id: "wordpress", 421 Id: "wordpress",
417 }, 422 },
418 expectContents: []params.EntityInfo{ 423 expectContents: []params.EntityInfo{
419 &params.ServiceInfo{ 424 &params.ServiceInfo{
420 Name: "wordpress", 425 Name: "wordpress",
421 Exposed: true, 426 Exposed: true,
422 CharmURL: "local:series/series-wordpress-3", 427 CharmURL: "local:series/series-wordpress-3",
423 Life: params.Life(Alive.String()), 428 Life: params.Life(Alive.String()),
429 MinUnits: 42,
424 Config: charm.Settings{}, 430 Config: charm.Settings{},
425 }, 431 },
426 }, 432 },
427 }, { 433 }, {
428 about: "service is updated if it's in backing and in multiwatche r.Store", 434 about: "service is updated if it's in backing and in multiwatche r.Store",
429 add: []params.EntityInfo{&params.ServiceInfo{ 435 add: []params.EntityInfo{&params.ServiceInfo{
430 Name: "wordpress", 436 Name: "wordpress",
431 Exposed: true, 437 Exposed: true,
432 CharmURL: "local:series/series-wordpress-3", 438 CharmURL: "local:series/series-wordpress-3",
439 MinUnits: 47,
433 Constraints: constraints.MustParse("mem=99M"), 440 Constraints: constraints.MustParse("mem=99M"),
434 Config: charm.Settings{"blog-title": "boring"}, 441 Config: charm.Settings{"blog-title": "boring"},
435 }}, 442 }},
436 setUp: func(c *C, st *State) { 443 setUp: func(c *C, st *State) {
437 svc, err := st.AddService("wordpress", AddTestingCharm(c , st, "wordpress")) 444 svc, err := st.AddService("wordpress", AddTestingCharm(c , st, "wordpress"))
438 c.Assert(err, IsNil) 445 c.Assert(err, IsNil)
439 setServiceConfigAttr(c, svc, "blog-title", "boring") 446 setServiceConfigAttr(c, svc, "blog-title", "boring")
440 }, 447 },
441 change: watcher.Change{ 448 change: watcher.Change{
442 C: "services", 449 C: "services",
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 panic(fmt.Errorf("%v mentioned twice in delta set", id)) 1028 panic(fmt.Errorf("%v mentioned twice in delta set", id))
1022 } 1029 }
1023 if d.Removed { 1030 if d.Removed {
1024 m[id] = nil 1031 m[id] = nil
1025 } else { 1032 } else {
1026 m[id] = d.Entity 1033 m[id] = d.Entity
1027 } 1034 }
1028 } 1035 }
1029 return m 1036 return m
1030 } 1037 }
OLDNEW
« no previous file with comments | « state/megawatcher.go ('k') | no next file » | no next file with comments »

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