@@ -150,6 +150,8 @@ func TestThatReloadCommandExecutesWhenNewFolderIsAdded(t *testing.T) {
150150 // wait for some time
151151 time .Sleep (500 * time .Millisecond )
152152
153+ startTime := time .Now ()
154+
153155 //modifyFS: create a new directory and file
154156 dir , err := ioutil .TempDir (tmpDir , "new-folder-" )
155157 if err != nil {
@@ -165,20 +167,20 @@ func TestThatReloadCommandExecutesWhenNewFolderIsAdded(t *testing.T) {
165167 time .Sleep (1000 * time .Millisecond )
166168
167169 status = sync .GetStatusInstance ()
168- // check that reload cmd has been executed
169- if time . Since ( status .LastSync ). Seconds () > 1 {
170- t .Fatal ("sync should have executed earlier than 1.5 but was executed " + time . Since ( status .LastSync ). String () )
170+
171+ if status .LastSync . Before ( startTime ) {
172+ t .Fatalf ("sync has not been executed since FS changes triggered at %s. Last sync time: %s" , startTime , status .LastSync )
171173 }
172- if time . Since ( status .LastReload ). Seconds () > 1 {
173- t .Fatal ("reload should have executed earlier than 1.5s but was executed " + time . Since ( status .LastReload ). String () )
174+ if status .LastReload . Before ( startTime ) {
175+ t .Fatalf ("reload has not been executed since FS changes triggered at %s. Last reload time: %s" , startTime , status .LastReload )
174176 }
175- if time . Since ( status .LastFSChangeDetected ). Seconds () > 1 {
176- t .Fatal ("FS changes should have been detected earlier than 1.5s but was detected " + time . Since ( status .LastFSChangeDetected ). String () )
177+ if status .LastFSChangeDetected . Before ( startTime ) {
178+ t .Fatalf ("FS changes have not been detected since FS changes triggered at %s. Last FS change detected at %s" , startTime , status .LastFSChangeDetected )
177179 }
178180
179181 // check that the reload_cmd.txt file was created when the reload command executed
180182 if _ , err := os .Stat (tmpDir + "/reload_cmd.txt" ); err != nil {
181- t .Fatal ("Expected to find the file created by the reload command " + tmpDir + "/reload_cmd.txt" )
183+ t .Fatalf ("Expected to find the file created by the reload command " + tmpDir + "/reload_cmd.txt" )
182184 }
183185
184186 //delete the tmp file and the TempDir
0 commit comments