Files
jiggablend/internal/runner/workspace/workspace_test.go
Justin Harms a3defe5cf6 Add tests for main package, manager, and various components
- Introduced unit tests for the main package to ensure compilation.
- Added tests for the manager, including validation of upload sessions and handling of Blender binary paths.
- Implemented tests for job token generation and validation, ensuring security and integrity.
- Created tests for configuration management and database schema to verify functionality.
- Added tests for logger and runner components to enhance overall test coverage and reliability.
2026-03-14 22:20:03 -05:00

41 lines
979 B
Go

package workspace
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestSanitizeName_ReplacesUnsafeChars(t *testing.T) {
got := sanitizeName("runner / with\\bad:chars")
if strings.ContainsAny(got, " /\\:") {
t.Fatalf("sanitizeName did not sanitize input: %q", got)
}
}
func TestFindBlendFiles_IgnoresBlendSaveFiles(t *testing.T) {
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "scene.blend"), []byte("x"), 0644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(dir, "scene.blend1"), []byte("x"), 0644); err != nil {
t.Fatal(err)
}
files, err := FindBlendFiles(dir)
if err != nil {
t.Fatalf("FindBlendFiles failed: %v", err)
}
if len(files) != 1 || files[0] != "scene.blend" {
t.Fatalf("unexpected files: %#v", files)
}
}
func TestFindFirstBlendFile_ReturnsErrorWhenMissing(t *testing.T) {
_, err := FindFirstBlendFile(t.TempDir())
if err == nil {
t.Fatal("expected error when no blend file exists")
}
}