Merge lp:~ericsnowcurrently/fake-juju/add-action-delta-handling into lp:~landscape/fake-juju/trunk-old

Proposed by Eric Snow
Status: Merged
Approved by: Eric Snow
Approved revision: 54
Merged at revision: 53
Proposed branch: lp:~ericsnowcurrently/fake-juju/add-action-delta-handling
Merge into: lp:~landscape/fake-juju/trunk-old
Diff against target: 51 lines (+26/-1)
1 file modified
2.0.0/fake-juju.go (+26/-1)
To merge this branch: bzr merge lp:~ericsnowcurrently/fake-juju/add-action-delta-handling
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
🤖 Landscape Builder test results Approve
Chad Smith Pending
Review via email: mp+311060@code.launchpad.net

Commit message

Add handling for action deltas.

Description of the change

Add handling for action deltas.

Testing instructions:

make test
...and run landscape's integration tests (once the txjuju fix lands).

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
review: Approve (test results)
Revision history for this message
Simon Poirier (simpoir) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '2.0.0/fake-juju.go'
2--- 2.0.0/fake-juju.go 2016-11-15 15:41:05 +0000
3+++ 2.0.0/fake-juju.go 2016-11-16 18:50:32 +0000
4@@ -754,6 +754,10 @@
5 unitId := entityId.Id
6 c.Assert(s.handleAddUnit(unitId), gc.IsNil)
7 }
8+ if entityId.Kind == "action" {
9+ actionId := entityId.Id
10+ c.Assert(s.handleAction(actionId), gc.IsNil)
11+ }
12 log.Println("Done processing delta")
13 }
14 }
15@@ -799,6 +803,28 @@
16 return nil
17 }
18
19+func (s *FakeJujuSuite) handleAction(id string) error {
20+ action, err := s.State.Action(id)
21+ log.Println("Handle action", id)
22+ if err != nil {
23+ log.Println("Got error with get action", err)
24+ return err
25+ }
26+ if action.Status() == state.ActionPending {
27+ log.Println("Action is pending")
28+ output := map[string]interface{}{"output": "action ran successfully"}
29+ results := state.ActionResults{
30+ Status: state.ActionCompleted,
31+ Results: output,
32+ }
33+ if _, err := action.Finish(results); err != nil {
34+ log.Println("Err on action results", err)
35+ return err
36+ }
37+ }
38+ return nil
39+}
40+
41 func (s *FakeJujuSuite) handleAddUnit(id string) error {
42 unit, err := s.State.Unit(id)
43 log.Println("Handle unit", id)
44@@ -906,7 +932,6 @@
45 if err != nil {
46 return err
47 }
48- return nil
49 for _, unit := range units {
50 unitStatus, _ := unit.Status()
51 if unitStatus.Status != states.Active {

Subscribers

People subscribed via source and target branches

to all changes: