Skip to content

Commit

Permalink
chore: add some milliseconds in client tests (#1178)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lance authored Aug 19, 2022
1 parent bfdbdbe commit 3ac5d46
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 3ac5d46

Please sign in to comment.