diff options
| author | Will Hawkins <[email protected]> | 2022-07-16 04:08:42 -0400 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2022-07-16 04:08:42 -0400 |
| commit | 23d16686f2320f9a5fe35aebbaa2e036b27421ca (patch) | |
| tree | c5e5d097f68fb9e7cfe2e3c794cfad4bc3266adb /utilities/utilities_test.go | |
| parent | f0a9f4a3a50b63127a5e3d4ab2bdda3bbe4d8d0d (diff) | |
[Feature] Support spec v2 (4/4); Add data logging
Besides work to complete the support for v2 of the RFC, this patch adds
support for logging each of the probe results to a CSV file
(--logger-filename).
Diffstat (limited to 'utilities/utilities_test.go')
| -rw-r--r-- | utilities/utilities_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/utilities/utilities_test.go b/utilities/utilities_test.go index 72a11fb..703243c 100644 --- a/utilities/utilities_test.go +++ b/utilities/utilities_test.go @@ -37,3 +37,26 @@ func TestReadAfterCloseOnBufferedChannel(t *testing.T) { t.Fatalf("Did not read all sent items from a buffered channel after channel.") } } + +func TestOrTimeoutStopsInfiniteLoop(t *testing.T) { + const TimeoutTime = 2 * time.Second + infinity := func() { + for { + } + } + timeBefore := time.Now() + OrTimeout(infinity, TimeoutTime) + timeAfter := time.Now() + if timeAfter.Sub(timeBefore) < TimeoutTime { + t.Fatalf("OrTimeout failed to keep the infinite loop running for at least %v.", TimeoutTime) + } +} + +func TestFilenameAppend(t *testing.T) { + const basename = "testing.csv" + const expected = "testing-appended.csv" + result := FilenameAppend(basename, "-appended") + if expected != result { + t.Fatalf("%s != %s for FilenameAppend.", expected, result) + } +} |
