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.
This commit is contained in:
35
internal/manager/blender_path.go
Normal file
35
internal/manager/blender_path.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// resolveBlenderBinaryPath resolves a Blender executable to an absolute path.
|
||||
func resolveBlenderBinaryPath(blenderBinary string) (string, error) {
|
||||
if blenderBinary == "" {
|
||||
return "", fmt.Errorf("blender binary path is empty")
|
||||
}
|
||||
|
||||
// Already contains a path component; normalize it.
|
||||
if strings.Contains(blenderBinary, string(filepath.Separator)) {
|
||||
absPath, err := filepath.Abs(blenderBinary)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to resolve blender binary path %q: %w", blenderBinary, err)
|
||||
}
|
||||
return absPath, nil
|
||||
}
|
||||
|
||||
// Bare executable name, resolve via PATH.
|
||||
resolvedPath, err := exec.LookPath(blenderBinary)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to locate blender binary %q in PATH: %w", blenderBinary, err)
|
||||
}
|
||||
absPath, err := filepath.Abs(resolvedPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to resolve blender binary path %q: %w", resolvedPath, err)
|
||||
}
|
||||
return absPath, nil
|
||||
}
|
||||
Reference in New Issue
Block a user