File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,49 @@ def controller.setup(container)
8484 end
8585 end
8686
87+ with "#restart" do
88+ it "replaces the running container with a new one" do
89+ def controller . setup ( container )
90+ container . spawn do |instance |
91+ instance . ready!
92+ sleep
93+ end
94+ end
95+
96+ controller . start
97+ first = controller . container
98+
99+ expect ( first ) . not . to be_nil
100+ expect ( controller ) . to be ( :running? )
101+
102+ # A restart is a blue-green swap: a new container is created and the old one is stopped.
103+ controller . restart
104+
105+ expect ( controller . container ) . not . to be_equal ( first )
106+ expect ( controller ) . to be ( :running? )
107+ ensure
108+ controller . stop ( false )
109+ end
110+
111+ it "starts a new container if not already running" do
112+ def controller . setup ( container )
113+ container . spawn do |instance |
114+ instance . ready!
115+ sleep
116+ end
117+ end
118+
119+ expect ( controller ) . not . to be ( :running? )
120+
121+ controller . restart
122+
123+ expect ( controller ) . to be ( :running? )
124+ expect ( controller . container ) . not . to be_nil
125+ ensure
126+ controller . stop ( false )
127+ end
128+ end
129+
87130 with "notify" do
88131 before do
89132 @notify_server = Async ::Container ::Notify ::Server . open
You can’t perform that action at this time.
0 commit comments