summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-02 21:54:05 +0300
committerPaul Buetow <paul@buetow.org>2026-04-02 21:54:05 +0300
commitd94fdaf92d7c66c012e819c73632be16f346b66f (patch)
treec8e39c8c81ecceb589722ab7179ce2e1f82bbba2
parent29f634d3413924af3a9dd6f89983c29b5320fe66 (diff)
task 00p: add -race to default test task; add t.Parallel() to safe unit tests
- Enable -race flag on the default 'task test' command so race conditions are caught by default, not only when running 'task test-race' - Add t.Parallel() to all tests in internal/image/prompt_test.go (pure function tests with no shared state) - Add t.Parallel() to TestReadBatchFile and its subtests in batch package (file I/O with t.TempDir(), no global state) - Add t.Parallel() to TestValidateBulgarianText and its subtests in audio package (pure string validation, no shared state) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--Taskfile.yaml4
-rw-r--r--internal/audio/validate_test.go2
-rw-r--r--internal/batch/processor_test.go3
-rw-r--r--internal/image/prompt_test.go6
4 files changed, 13 insertions, 2 deletions
diff --git a/Taskfile.yaml b/Taskfile.yaml
index f4588d1..2158167 100644
--- a/Taskfile.yaml
+++ b/Taskfile.yaml
@@ -8,9 +8,9 @@ tasks:
cmds:
- go run ./cmd/totalrecall
test:
- desc: Run all tests
+ desc: Run all tests with race detector
cmds:
- - go test ./...
+ - go test -race ./...
test-verbose:
desc: Run all tests with verbose output
diff --git a/internal/audio/validate_test.go b/internal/audio/validate_test.go
index 7bc3c9e..4b3392f 100644
--- a/internal/audio/validate_test.go
+++ b/internal/audio/validate_test.go
@@ -6,6 +6,7 @@ import (
)
func TestValidateBulgarianText(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
text string
@@ -50,6 +51,7 @@ func TestValidateBulgarianText(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
err := ValidateBulgarianText(tt.text)
if (err != nil) != tt.wantErr {
t.Errorf("ValidateBulgarianText() error = %v, wantErr %v", err, tt.wantErr)
diff --git a/internal/batch/processor_test.go b/internal/batch/processor_test.go
index 8bc8079..4ec1739 100644
--- a/internal/batch/processor_test.go
+++ b/internal/batch/processor_test.go
@@ -10,6 +10,7 @@ import (
)
func TestReadBatchFile(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
fileContent string
@@ -136,6 +137,7 @@ func TestReadBatchFile(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
// Create temp file
tmpDir := t.TempDir()
tmpFile := filepath.Join(tmpDir, "test.txt")
@@ -157,6 +159,7 @@ func TestReadBatchFile(t *testing.T) {
}
func TestReadBatchFile_FileNotFound(t *testing.T) {
+ t.Parallel()
_, err := ReadBatchFile("/nonexistent/file.txt")
if err == nil {
t.Error("Expected error for non-existent file")
diff --git a/internal/image/prompt_test.go b/internal/image/prompt_test.go
index 1961ce2..41172e3 100644
--- a/internal/image/prompt_test.go
+++ b/internal/image/prompt_test.go
@@ -6,18 +6,21 @@ import (
)
func TestPromptSubjectUsesTranslationFirst(t *testing.T) {
+ t.Parallel()
if got := promptSubject(" apple ", "ябълка"); got != "apple" {
t.Fatalf("promptSubject() = %q, want %q", got, "apple")
}
}
func TestPromptSubjectFallsBackToOriginalWord(t *testing.T) {
+ t.Parallel()
if got := promptSubject(" ", "ябълка"); got != "ябълка" {
t.Fatalf("promptSubject() = %q, want %q", got, "ябълка")
}
}
func TestSanitizeSceneDescriptionRemovesLabelsAndFences(t *testing.T) {
+ t.Parallel()
scene := "```text\nScene: A bright apple sits centered on a wooden table.\n```"
if got := sanitizeSceneDescription(scene); got != "A bright apple sits centered on a wooden table" {
t.Fatalf("sanitizeSceneDescription() = %q", got)
@@ -25,6 +28,7 @@ func TestSanitizeSceneDescriptionRemovesLabelsAndFences(t *testing.T) {
}
func TestUsableSceneDescriptionRejectsTrivialContent(t *testing.T) {
+ t.Parallel()
if usableSceneDescription("A") {
t.Fatal("usableSceneDescription() unexpectedly accepted trivial scene")
}
@@ -34,6 +38,7 @@ func TestUsableSceneDescriptionRejectsTrivialContent(t *testing.T) {
}
func TestFallbackVisualDirectionForPhrase(t *testing.T) {
+ t.Parallel()
got := fallbackVisualDirection("to indulge someone")
if got == "" || !usableSceneDescription(got) {
t.Fatalf("fallbackVisualDirection() returned unusable phrase direction: %q", got)
@@ -41,6 +46,7 @@ func TestFallbackVisualDirectionForPhrase(t *testing.T) {
}
func TestFallbackVisualDirectionForSingleWord(t *testing.T) {
+ t.Parallel()
got := fallbackVisualDirection("apple")
if got == "" || !strings.Contains(got, "single apple") {
t.Fatalf("fallbackVisualDirection() = %q", got)