File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
test/async/container/notify Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 77require "async/container/controllers"
88
99require "tmpdir"
10+ require "bake"
1011
11- describe Async ::Container ::Notify ::Pipe do
12+ describe Async ::Container ::Notify ::Log do
1213 let ( :notify_script ) { Async ::Container ::Controllers . path_for ( "notify" ) }
1314 let ( :notify_log ) { File . expand_path ( "notify-#{ ::Process . pid } -#{ SecureRandom . hex ( 8 ) } .log" , Dir . tmpdir ) }
15+ let ( :notify ) { Async ::Container ::Notify ::Log . open! ( { "NOTIFY_LOG" => notify_log } ) }
1416
17+ after do
18+ File . unlink ( notify_log ) rescue nil
19+ end
20+
1521 it "receives notification of child status" do
1622 system ( { "NOTIFY_LOG" => notify_log } , "bundle" , "exec" , notify_script )
1723
2228 "size" => be > 0 ,
2329 )
2430 end
31+
32+ with "async:container:notify:log:ready?" do
33+ let ( :context ) { Bake ::Context . load }
34+ let ( :recipe ) { context . lookup ( "async:container:notify:log:ready?" ) }
35+
36+ it "fails if the log file does not exist" do
37+ expect do
38+ recipe . call ( path : "nonexistant.log" )
39+ end . to raise_exception ( RuntimeError , message : be =~ /log file does not exist/i )
40+ end
41+
42+ it "succeeds if the log file exists and is ready" do
43+ notify . ready!
44+
45+ expect ( recipe . call ( path : notify_log ) ) . to be == true
46+ end
47+
48+ it "fails if the log file exists but is not ready" do
49+ notify . status! ( "Loading..." )
50+
51+ expect do
52+ expect ( recipe . call ( path : notify_log ) )
53+ end . to raise_exception ( RuntimeError , message : be =~ /service is not ready/i )
54+ end
55+ end
2556end
You can’t perform that action at this time.
0 commit comments