diff --git a/internal/conversion/worker_test.go b/internal/conversion/worker_test.go index 9b2cab58..37894b64 100644 --- a/internal/conversion/worker_test.go +++ b/internal/conversion/worker_test.go @@ -687,3 +687,38 @@ func TestConvertOperation_InvalidStorageFormat(t *testing.T) { assert.Error(t, err) assert.Contains(t, err.Error(), "get storage engine") } + +func TestConvertOperation_JSONFileNotFound(t *testing.T) { + dir := t.TempDir() + // Don't create the JSON file - test the "file not found" error path + + repo := newErrorMockRepo() + worker := NewWorker(repo, Config{ + DataDir: dir, + }) + + ctx := context.Background() + err := worker.ConvertOne(ctx, 1, "nonexistent") + + assert.Error(t, err) + assert.Contains(t, err.Error(), "JSON file not found") +} + +func TestTriggerConversion_FailedStatusUpdateError(t *testing.T) { + dir := t.TempDir() + // Don't create the JSON file - will fail and try to update status to "failed" + + repo := newErrorMockRepo() + // Make status updates fail after the initial "converting" update + repo.updateStatusErr = fmt.Errorf("status update failed") + + worker := NewWorker(repo, Config{ + DataDir: dir, + }) + + // TriggerConversion is async, just verify it doesn't panic + worker.TriggerConversion(1, "nonexistent") + + // Give the goroutine time to run + time.Sleep(100 * time.Millisecond) +} diff --git a/internal/server/marker_test.go b/internal/server/marker_test.go index de0db48a..d739b75f 100644 --- a/internal/server/marker_test.go +++ b/internal/server/marker_test.go @@ -424,6 +424,32 @@ func TestScanDir(t *testing.T) { }) } +func TestPaintSVG_InvalidTemplate(t *testing.T) { + dir := t.TempDir() + + // Create SVG with invalid template syntax + invalidPath := filepath.Join(dir, "invalid.svg") + err := os.WriteFile(invalidPath, []byte(`{{ .Unclosed`), 0644) + require.NoError(t, err) + + c := color.RGBA{255, 0, 0, 255} + _, err = paintSVG(invalidPath, c) + assert.Error(t, err) +} + +func TestPaintPNG_InvalidImage(t *testing.T) { + dir := t.TempDir() + + // Create file with .png extension but invalid image data + invalidPath := filepath.Join(dir, "invalid.png") + err := os.WriteFile(invalidPath, []byte("not a valid png"), 0644) + require.NoError(t, err) + + c := color.RGBA{255, 0, 0, 255} + _, err = paintPNG(invalidPath, c) + assert.Error(t, err) +} + func TestMax(t *testing.T) { tests := []struct { a, b, want uint8