summaryrefslogtreecommitdiff
path: root/internal/timer/operations_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-28 23:28:17 +0300
committerPaul Buetow <paul@buetow.org>2025-09-28 23:28:17 +0300
commit7bc3e0d8dea4989325203987405ce31d0257fd19 (patch)
tree51d9d9241397f22606009e32c22eeb4dcb97b8ec /internal/timer/operations_test.go
parent5d0532428300d048dbc47acfa08f77b8dc9c32bb (diff)
add continue
Diffstat (limited to 'internal/timer/operations_test.go')
-rw-r--r--internal/timer/operations_test.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/timer/operations_test.go b/internal/timer/operations_test.go
index 68eb4af..0cb86fc 100644
--- a/internal/timer/operations_test.go
+++ b/internal/timer/operations_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strconv"
"testing"
"time"
)
@@ -12,9 +13,9 @@ import (
func setup(t *testing.T) {
t.Helper()
tempDir := t.TempDir()
- stateFilePathOverride = filepath.Join(tempDir, ".timr_state")
+ StateFilePathOverride = filepath.Join(tempDir, ".timr_state")
t.Cleanup(func() {
- stateFilePathOverride = ""
+ StateFilePathOverride = ""
})
}
@@ -118,7 +119,7 @@ func TestGetRawStatus(t *testing.T) {
if err != nil {
t.Fatalf("GetRawStatus() error = %v", err)
}
- want := "0"
+ want := "0.000000"
if msg != want {
t.Errorf("GetRawStatus() msg = %q, want %q", msg, want)
}
@@ -139,9 +140,13 @@ func TestGetRawStatus(t *testing.T) {
if err != nil {
t.Fatalf("GetRawStatus() error = %v", err)
}
- want = "2"
- if msg != want {
- t.Errorf("GetRawStatus() msg = %q, want %q", msg, want)
+ // we can't know the exact float, so we check if it's close to 2
+ val, err := strconv.ParseFloat(msg, 64)
+ if err != nil {
+ t.Fatalf("could not parse float: %v", err)
+ }
+ if val < 1.9 || val > 2.1 {
+ t.Errorf("GetRawStatus() msg = %q, want around 2.0", msg)
}
}