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:
32
internal/auth/secrets_test.go
Normal file
32
internal/auth/secrets_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenerateSecret_Length(t *testing.T) {
|
||||
secret, err := generateSecret(8)
|
||||
if err != nil {
|
||||
t.Fatalf("generateSecret failed: %v", err)
|
||||
}
|
||||
// hex encoding doubles length
|
||||
if len(secret) != 16 {
|
||||
t.Fatalf("unexpected secret length: %d", len(secret))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateAPIKey_Format(t *testing.T) {
|
||||
s := &Secrets{}
|
||||
key, err := s.generateAPIKey()
|
||||
if err != nil {
|
||||
t.Fatalf("generateAPIKey failed: %v", err)
|
||||
}
|
||||
if !strings.HasPrefix(key, "jk_r") {
|
||||
t.Fatalf("unexpected key prefix: %q", key)
|
||||
}
|
||||
if !strings.Contains(key, "_") {
|
||||
t.Fatalf("unexpected key format: %q", key)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user