@@ -59,13 +59,18 @@ func TestWatch(t *testing.T) {
5959func doTest (t * testing.T , svcName string , tarSync bool ) {
6060 tmpdir := t .TempDir ()
6161 dataDir := filepath .Join (tmpdir , "data" )
62- writeDataFile := func (name string , contents string ) {
62+ configDir := filepath .Join (tmpdir , "config" )
63+
64+ writeTestFile := func (name , contents , sourceDir string ) {
6365 t .Helper ()
64- dest := filepath .Join (dataDir , name )
66+ dest := filepath .Join (sourceDir , name )
6567 require .NoError (t , os .MkdirAll (filepath .Dir (dest ), 0o700 ))
6668 t .Logf ("writing %q to %q" , contents , dest )
6769 require .NoError (t , os .WriteFile (dest , []byte (contents + "\n " ), 0o600 ))
6870 }
71+ writeDataFile := func (name , contents string ) {
72+ writeTestFile (name , contents , dataDir )
73+ }
6974
7075 composeFilePath := filepath .Join (tmpdir , "compose.yaml" )
7176 CopyFile (t , filepath .Join ("fixtures" , "watch" , "compose.yaml" ), composeFilePath )
@@ -195,5 +200,20 @@ func doTest(t *testing.T, svcName string, tarSync bool) {
195200 Err : "No such file or directory" ,
196201 })
197202
203+ t .Logf ("Sync and restart use case" )
204+ require .NoError (t , os .Mkdir (configDir , 0o700 ))
205+ writeTestFile ("file.config" , "This is an updated config file" , configDir )
206+ checkRestart := func (state string ) poll.Check {
207+ return func (pollLog poll.LogT ) poll.Result {
208+ if strings .Contains (r .Combined (), state ) {
209+ return poll .Success ()
210+ }
211+ return poll .Continue (r .Combined ())
212+ }
213+ }
214+ poll .WaitOn (t , checkRestart (fmt .Sprintf ("%s-1 Restarting" , svcName )))
215+ poll .WaitOn (t , checkRestart (fmt .Sprintf ("%s-1 Started" , svcName )))
216+ poll .WaitOn (t , checkFileContents ("/app/config/file.config" , "This is an updated config file" ))
217+
198218 testComplete .Store (true )
199219}
0 commit comments