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:
42
internal/runner/tasks/processor_test.go
Normal file
42
internal/runner/tasks/processor_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"jiggablend/pkg/types"
|
||||
)
|
||||
|
||||
func TestNewContext_NormalizesFrameEnd(t *testing.T) {
|
||||
ctx := NewContext(1, 2, "job", 10, 1, "render", "/tmp", "tok", nil, nil, nil, nil, nil, nil, nil, false, false, false, false, false, false, nil)
|
||||
if ctx.FrameEnd != 10 {
|
||||
t.Fatalf("expected FrameEnd to be normalized to Frame, got %d", ctx.FrameEnd)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext_GetOutputFormat_Default(t *testing.T) {
|
||||
ctx := &Context{}
|
||||
if got := ctx.GetOutputFormat(); got != "PNG" {
|
||||
t.Fatalf("GetOutputFormat() = %q, want PNG", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext_ShouldForceCPU(t *testing.T) {
|
||||
ctx := &Context{ForceCPURendering: true}
|
||||
if !ctx.ShouldForceCPU() {
|
||||
t.Fatal("expected force cpu when runner-level flag is set")
|
||||
}
|
||||
|
||||
force := true
|
||||
ctx = &Context{Metadata: &types.BlendMetadata{RenderSettings: types.RenderSettings{EngineSettings: map[string]interface{}{"force_cpu": force}}}}
|
||||
if !ctx.ShouldForceCPU() {
|
||||
t.Fatal("expected force cpu when metadata requests it")
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrJobCancelled_IsSentinel(t *testing.T) {
|
||||
if !errors.Is(ErrJobCancelled, ErrJobCancelled) {
|
||||
t.Fatal("sentinel error should be self-identical")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user