| 96 | } |
| 97 | |
| 98 | func TestPlanStringWithGroup(t *testing.T) { |
| 99 | p := &Plan{} |
| 100 | create := p.addNode(Operation{ |
| 101 | Type: OpCreateContainer, |
| 102 | ResourceID: "service:web:1", |
| 103 | Cause: "config hash changed (tmpName)", |
| 104 | }, "recreate:web:1") |
| 105 | stop := p.addNode(Operation{ |
| 106 | Type: OpStopContainer, |
| 107 | ResourceID: "service:web:1", |
| 108 | Cause: "replaced by #1", |
| 109 | }, "recreate:web:1", create) |
| 110 | remove := p.addNode(Operation{ |
| 111 | Type: OpRemoveContainer, |
| 112 | ResourceID: "service:web:1", |
| 113 | Cause: "replaced by #1", |
| 114 | }, "recreate:web:1", stop) |
| 115 | p.addNode(Operation{ |
| 116 | Type: OpRenameContainer, |
| 117 | ResourceID: "service:web:1", |
| 118 | Cause: "finalize recreate", |
| 119 | }, "recreate:web:1", remove) |
| 120 | |
| 121 | expected := "[] -> #1 service:web:1, CreateContainer, config hash changed (tmpName) [recreate:web:1]\n" + |
| 122 | "[1] -> #2 service:web:1, StopContainer, replaced by #1 [recreate:web:1]\n" + |
| 123 | "[2] -> #3 service:web:1, RemoveContainer, replaced by #1 [recreate:web:1]\n" + |
| 124 | "[3] -> #4 service:web:1, RenameContainer, finalize recreate [recreate:web:1]\n" |
| 125 | assert.Equal(t, p.String(), expected) |
| 126 | } |
| 127 | |
| 128 | func TestPlanAddNodeAutoIncrements(t *testing.T) { |
| 129 | p := &Plan{} |