Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions internal/conversion/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
26 changes: 26 additions & 0 deletions internal/server/marker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`<svg>{{ .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
Expand Down
Loading