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:
40
internal/runner/runner_test.go
Normal file
40
internal/runner/runner_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewRunner_InitializesFields(t *testing.T) {
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false)
|
||||
if r == nil {
|
||||
t.Fatal("New should return a runner")
|
||||
}
|
||||
if r.name != "runner-a" || r.hostname != "host-a" {
|
||||
t.Fatalf("unexpected runner identity: %q %q", r.name, r.hostname)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunner_GPUFlagsSetters(t *testing.T) {
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false)
|
||||
r.SetGPULockedOut(true)
|
||||
if !r.IsGPULockedOut() {
|
||||
t.Fatal("expected GPU lockout to be true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateFingerprint_PopulatesValue(t *testing.T) {
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false)
|
||||
r.generateFingerprint()
|
||||
fp := r.GetFingerprint()
|
||||
if fp == "" {
|
||||
t.Fatal("fingerprint should not be empty")
|
||||
}
|
||||
if len(fp) != 64 {
|
||||
t.Fatalf("fingerprint should be sha256 hex, got %q", fp)
|
||||
}
|
||||
if _, err := hex.DecodeString(fp); err != nil {
|
||||
t.Fatalf("fingerprint should be valid hex: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user