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

Unified Diff: state/unit_test.go

Issue 6571047: state: safer entity watchers
Patch Set: state: safer entity watchers Created 12 years, 6 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « state/service_test.go ('k') | state/watcher.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: state/unit_test.go
=== modified file 'state/unit_test.go'
--- state/unit_test.go 2012-09-24 21:31:51 +0000
+++ state/unit_test.go 2012-09-25 08:28:02 +0000
@@ -355,6 +355,13 @@
}
func (s *UnitSuite) TestWatchUnit(c *C) {
+ altunit, err := s.State.Unit(s.unit.Name())
+ c.Assert(err, IsNil)
+ err = altunit.SetPublicAddress("newer-address")
+ c.Assert(err, IsNil)
+ _, err = s.unit.PublicAddress()
+ c.Assert(err, ErrorMatches, `public address of unit ".*" not found`)
+
w := s.unit.Watch()
defer func() {
c.Assert(w.Stop(), IsNil)
@@ -364,6 +371,9 @@
case u, ok := <-w.Changes():
c.Assert(ok, Equals, true)
c.Assert(u.Name(), Equals, s.unit.Name())
+ addr, err := u.PublicAddress()
+ c.Assert(err, IsNil)
+ c.Assert(addr, Equals, "newer-address")
case <-time.After(500 * time.Millisecond):
c.Fatalf("did not get change: %v", s.unit)
}
« no previous file with comments | « state/service_test.go ('k') | state/watcher.go » ('j') | no next file with comments »

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