LEFT | RIGHT |
1 package state_test | 1 package state_test |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 . "launchpad.net/gocheck" | 5 . "launchpad.net/gocheck" |
6 "launchpad.net/juju-core/charm" | 6 "launchpad.net/juju-core/charm" |
7 "launchpad.net/juju-core/state" | 7 "launchpad.net/juju-core/state" |
8 "sort" | 8 "sort" |
9 "strings" | 9 "strings" |
10 "time" | 10 "time" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 703 |
704 // ...and check that the first relation unit sees the change. | 704 // ...and check that the first relation unit sees the change. |
705 s1, err := ru1.Settings() | 705 s1, err := ru1.Settings() |
706 c.Assert(err, IsNil) | 706 c.Assert(err, IsNil) |
707 expectChanged := map[string]map[string]interface{}{ | 707 expectChanged := map[string]map[string]interface{}{ |
708 "peer/1": s1.Map(), | 708 "peer/1": s1.Map(), |
709 } | 709 } |
710 s.assertChange(c, w0, []string{"peer/1"}, expectChanged, nil) | 710 s.assertChange(c, w0, []string{"peer/1"}, expectChanged, nil) |
711 s.assertNoChange(c, w0) | 711 s.assertNoChange(c, w0) |
712 | 712 |
| 713 // Join again, check it's a no-op. |
| 714 err = ru1.EnterScope() |
| 715 c.Assert(err, IsNil) |
| 716 s.assertNoChange(c, w0) |
| 717 |
713 // Start watching the relation from the perspective of the second unit, | 718 // Start watching the relation from the perspective of the second unit, |
714 // and check that it sees the right state. | 719 // and check that it sees the right state. |
715 w1 := ru1.Watch() | 720 w1 := ru1.Watch() |
716 defer stop(c, w1) | 721 defer stop(c, w1) |
717 expectChanged = map[string]map[string]interface{}{ | 722 expectChanged = map[string]map[string]interface{}{ |
718 "peer/0": s0.Map(), | 723 "peer/0": s0.Map(), |
719 } | 724 } |
720 s.assertChange(c, w1, []string{"peer/0"}, expectChanged, nil) | 725 s.assertChange(c, w1, []string{"peer/0"}, expectChanged, nil) |
721 s.assertNoChange(c, w1) | 726 s.assertNoChange(c, w1) |
722 | 727 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 c.Assert(err, IsNil) | 868 c.Assert(err, IsNil) |
864 reqs0, err := reqru0.Settings() | 869 reqs0, err := reqru0.Settings() |
865 c.Assert(err, IsNil) | 870 c.Assert(err, IsNil) |
866 expectJoined = []string{"req/0"} | 871 expectJoined = []string{"req/0"} |
867 expectChanged = map[string]map[string]interface{}{ | 872 expectChanged = map[string]map[string]interface{}{ |
868 "req/0": reqs0.Map(), | 873 "req/0": reqs0.Map(), |
869 } | 874 } |
870 s.assertChange(c, prow0, expectJoined, expectChanged, nil) | 875 s.assertChange(c, prow0, expectJoined, expectChanged, nil) |
871 s.assertNoChange(c, prow0) | 876 s.assertNoChange(c, prow0) |
872 s.assertChange(c, prow1, expectJoined, expectChanged, nil) | 877 s.assertChange(c, prow1, expectJoined, expectChanged, nil) |
| 878 s.assertNoChange(c, prow1) |
| 879 |
| 880 // Join again, check no-op. |
| 881 err = reqru0.EnterScope() |
| 882 c.Assert(err, IsNil) |
| 883 s.assertNoChange(c, prow0) |
873 s.assertNoChange(c, prow1) | 884 s.assertNoChange(c, prow1) |
874 | 885 |
875 // Join the second requirer, and check the provider units see the change
. | 886 // Join the second requirer, and check the provider units see the change
. |
876 err = reqru1.EnterScope() | 887 err = reqru1.EnterScope() |
877 c.Assert(err, IsNil) | 888 c.Assert(err, IsNil) |
878 reqs1, err := reqru1.Settings() | 889 reqs1, err := reqru1.Settings() |
879 c.Assert(err, IsNil) | 890 c.Assert(err, IsNil) |
880 expectJoined = []string{"req/1"} | 891 expectJoined = []string{"req/1"} |
881 expectChanged = map[string]map[string]interface{}{ | 892 expectChanged = map[string]map[string]interface{}{ |
882 "req/1": reqs1.Map(), | 893 "req/1": reqs1.Map(), |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 } | 1125 } |
1115 | 1126 |
1116 func (s *OriginalRelationUnitSuite) assertNoChange(c *C, w *state.RelationUnitsW
atcher) { | 1127 func (s *OriginalRelationUnitSuite) assertNoChange(c *C, w *state.RelationUnitsW
atcher) { |
1117 s.State.StartSync() | 1128 s.State.StartSync() |
1118 select { | 1129 select { |
1119 case ch := <-w.Changes(): | 1130 case ch := <-w.Changes(): |
1120 c.Fatalf("got %#v, expected nothing", ch) | 1131 c.Fatalf("got %#v, expected nothing", ch) |
1121 case <-time.After(50 * time.Millisecond): | 1132 case <-time.After(50 * time.Millisecond): |
1122 } | 1133 } |
1123 } | 1134 } |
LEFT | RIGHT |