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:
49
pkg/types/types_test.go
Normal file
49
pkg/types/types_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestJobJSON_RoundTrip(t *testing.T) {
|
||||
now := time.Now().UTC().Truncate(time.Second)
|
||||
frameStart, frameEnd := 1, 10
|
||||
format := "PNG"
|
||||
job := Job{
|
||||
ID: 42,
|
||||
UserID: 7,
|
||||
JobType: JobTypeRender,
|
||||
Name: "demo",
|
||||
Status: JobStatusPending,
|
||||
Progress: 12.5,
|
||||
FrameStart: &frameStart,
|
||||
FrameEnd: &frameEnd,
|
||||
OutputFormat: &format,
|
||||
BlendMetadata: &BlendMetadata{
|
||||
FrameStart: 1,
|
||||
FrameEnd: 10,
|
||||
RenderSettings: RenderSettings{
|
||||
ResolutionX: 1920,
|
||||
ResolutionY: 1080,
|
||||
FrameRate: 24.0,
|
||||
},
|
||||
},
|
||||
CreatedAt: now,
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(job)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal failed: %v", err)
|
||||
}
|
||||
|
||||
var out Job
|
||||
if err := json.Unmarshal(raw, &out); err != nil {
|
||||
t.Fatalf("unmarshal failed: %v", err)
|
||||
}
|
||||
|
||||
if out.ID != job.ID || out.JobType != JobTypeRender || out.BlendMetadata == nil {
|
||||
t.Fatalf("unexpected roundtrip result: %+v", out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user