File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,13 +120,18 @@ def setup(container)
120120 end
121121
122122 # Start the container unless it's already running.
123+ # @returns [Boolean] Whether a new container was started.
123124 def start
124125 unless @container
125126 Console . info ( self , "Controller starting..." )
126127 self . restart
128+
129+ Console . info ( self , "Controller started." )
130+
131+ return true
127132 end
128133
129- Console . info ( self , "Controller started." )
134+ return false
130135 end
131136
132137 # Stop the container if it's running.
Original file line number Diff line number Diff line change @@ -139,6 +139,21 @@ def controller.setup(container)
139139 expect ( controller . container ) . to be_nil
140140 end
141141
142+ it "doesn't restart a container if it's already running" do
143+ expect ( controller ) . to receive ( :setup )
144+
145+ expect ( controller . start ) . to be == true
146+ expect ( controller ) . to be ( :running? )
147+
148+ container = controller . container
149+
150+ # Starting again is idempotent: it returns false and the container is not replaced.
151+ expect ( controller . start ) . to be == false
152+ expect ( controller . container ) . to be_equal ( container )
153+ ensure
154+ controller . stop
155+ end
156+
142157 it "can spawn a reactor" do
143158 def controller . setup ( container )
144159 container . async do |task |
You can’t perform that action at this time.
0 commit comments