@@ -104,8 +104,12 @@ defmodule SetDiskFreeLimitCommandTest do
104104 test "run: a valid integer input returns an ok and sets the disk free limit" , context do
105105 set_disk_free_limit ( @ default_limit )
106106 assert @ command . run ( [ context [ :limit ] ] , context [ :opts ] ) == :ok
107- Process . sleep ( 500 )
108- assert status ( ) [ :disk_free_limit ] === context [ :limit ]
107+ await_condition (
108+ fn ->
109+ status ( ) [ :disk_free_limit ] === context [ :limit ]
110+ end ,
111+ 60000
112+ )
109113
110114 set_disk_free_limit ( @ default_limit )
111115 end
@@ -115,8 +119,12 @@ defmodule SetDiskFreeLimitCommandTest do
115119 context do
116120 set_disk_free_limit ( @ default_limit )
117121 assert @ command . run ( [ context [ :limit ] ] , context [ :opts ] ) == :ok
118- Process . sleep ( 500 )
119- assert status ( ) [ :disk_free_limit ] === round ( context [ :limit ] )
122+ await_condition (
123+ fn ->
124+ status ( ) [ :disk_free_limit ] === round ( context [ :limit ] )
125+ end ,
126+ 60000
127+ )
120128
121129 set_disk_free_limit ( @ default_limit )
122130 end
@@ -126,8 +134,12 @@ defmodule SetDiskFreeLimitCommandTest do
126134 context do
127135 set_disk_free_limit ( @ default_limit )
128136 assert @ command . run ( [ context [ :limit ] ] , context [ :opts ] ) == :ok
129- Process . sleep ( 500 )
130- assert status ( ) [ :disk_free_limit ] === context [ :limit ] |> Float . floor ( ) |> round
137+ await_condition (
138+ fn ->
139+ status ( ) [ :disk_free_limit ] === context [ :limit ] |> Float . floor ( ) |> round
140+ end ,
141+ 60000
142+ )
131143
132144 set_disk_free_limit ( @ default_limit )
133145 end
@@ -136,17 +148,25 @@ defmodule SetDiskFreeLimitCommandTest do
136148 test "run: an integer string input returns an ok and sets the disk free limit" , context do
137149 set_disk_free_limit ( @ default_limit )
138150 assert @ command . run ( [ context [ :limit ] ] , context [ :opts ] ) == :ok
139- Process . sleep ( 500 )
140- assert status ( ) [ :disk_free_limit ] === String . to_integer ( context [ :limit ] )
151+ await_condition (
152+ fn ->
153+ status ( ) [ :disk_free_limit ] === String . to_integer ( context [ :limit ] )
154+ end ,
155+ 60000
156+ )
141157
142158 set_disk_free_limit ( @ default_limit )
143159 end
144160
145161 @ tag limit: "2MB"
146162 test "run: an valid unit string input returns an ok and changes the limit" , context do
147163 assert @ command . run ( [ context [ :limit ] ] , context [ :opts ] ) == :ok
148- Process . sleep ( 500 )
149- assert status ( ) [ :disk_free_limit ] === 2_000_000
164+ await_condition (
165+ fn ->
166+ status ( ) [ :disk_free_limit ] === 2_000_000
167+ end ,
168+ 60000
169+ )
150170
151171 set_disk_free_limit ( @ default_limit )
152172 end
0 commit comments