chore: add some milliseconds in client tests (#1178)

The client test which checks for rebuilds based on timestamps is
consistently failing in CI. This change may alleviate that problem.

Signed-off-by: Lance Ball <lball@redhat.com>

Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
Lance Ball 2022-08-19 10:49:52 -04:00 committed by GitHub
parent bfdbdbebe8
commit 3ac5d468bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1400,10 +1400,17 @@ func TestClient_BuiltDetects(t *testing.T) {
t.Fatal("freshly built function reported Built==false (1)")
}
// Release thread and wait to ensure that the clock advances even in constrained CI environments
time.Sleep(100 * time.Millisecond)
// Edit the filesystem by touching a file (updating modified timestamp)
if err := os.Chtimes(filepath.Join(root, "func.yaml"), time.Now(), time.Now()); err != nil {
fmt.Println(err)
}
// Release thread and wait to ensure that the clock advances even in constrained CI environments
time.Sleep(100 * time.Millisecond)
if client.Built(root) {
t.Fatal("client did not detect file timestamp change as indicating build staleness")
}