From efb39cfd4e840aa4bf57511ad25c6ab635858653 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Sat, 23 May 2015 21:20:39 +0200 Subject: [PATCH] Fix file SD test --- retrieval/discovery/file_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/retrieval/discovery/file_test.go b/retrieval/discovery/file_test.go index 5b9f90fcc..8ae0ef8ab 100644 --- a/retrieval/discovery/file_test.go +++ b/retrieval/discovery/file_test.go @@ -81,17 +81,24 @@ func testFileSD(t *testing.T, ext string) { // Below we will change the file to a bad syntax. Previously extracted target // groups must not be deleted via sending an empty target group. if len(tg.Targets) == 0 { - t.Fatalf("Unexpected empty target group received: %s", tg) + t.Errorf("Unexpected empty target group received: %s", tg) } } }() - newf, err = os.Create("fixtures/_test" + ext) + newf, err = os.Create("fixtures/_test.new") if err != nil { t.Fatal(err) } + defer os.Remove(newf.Name()) + if _, err := newf.Write([]byte("]gibberish\n][")); err != nil { t.Fatal(err) } newf.Close() + + os.Rename(newf.Name(), "fixtures/_test"+ext) + + // Give notifcations some time to arrive. + time.Sleep(50 * time.Millisecond) }