mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* tests: swap testify for test in plugins/csi/client_test.go * tests: swap testify for test in testutil/ * tests: swap testify for test in host_test.go * tests: swap testify for test in plugin_test.go * tests: swap testify for test in utils_test.go * tests: swap testify for test in scheduler/ * tests: swap testify for test in parse_test.go * tests: swap testify for test in attribute_test.go * tests: swap testify for test in plugins/drivers/ * tests: swap testify for test in command/ * tests: fixup some test usages * go: run go mod tidy * windows: cpuset test only on linux
46 lines
762 B
Go
46 lines
762 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package testutil
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
func TestWait_WaitForFilesUntil(t *testing.T) {
|
|
|
|
N := 10
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
var files []string
|
|
for i := 1; i < N; i++ {
|
|
files = append(files, filepath.Join(
|
|
tmpDir, fmt.Sprintf("test%d.txt", i),
|
|
))
|
|
}
|
|
|
|
go func() {
|
|
for _, file := range files {
|
|
t.Logf("Creating file %s ...", file)
|
|
fh, createErr := os.Create(file)
|
|
must.NoError(t, createErr)
|
|
|
|
must.Close(t, fh)
|
|
must.FileExists(t, file)
|
|
|
|
time.Sleep(250 * time.Millisecond)
|
|
}
|
|
}()
|
|
|
|
duration := 5 * time.Second
|
|
t.Log("Waiting 5 seconds for files ...")
|
|
WaitForFilesUntil(t, files, duration)
|
|
}
|