- internal/platform: cross-platform path detection, 6 tests - internal/auth: JWT generation/validation + bcrypt, 8 tests - 89 total tests, build + vet clean
65 lines
1.2 KiB
Go
65 lines
1.2 KiB
Go
package platform
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
func TestDetect(t *testing.T) {
|
|
p := Detect()
|
|
|
|
if p.OS != runtime.GOOS {
|
|
t.Errorf("expected OS=%s, got %s", runtime.GOOS, p.OS)
|
|
}
|
|
if p.Arch != runtime.GOARCH {
|
|
t.Errorf("expected Arch=%s, got %s", runtime.GOARCH, p.Arch)
|
|
}
|
|
if runtime.GOOS == "linux" && !p.IsLinux {
|
|
t.Error("expected IsLinux=true on Linux")
|
|
}
|
|
}
|
|
|
|
func TestDataDir(t *testing.T) {
|
|
p := Detect()
|
|
dir := p.DataDir()
|
|
if dir == "" {
|
|
t.Error("DataDir should not be empty")
|
|
}
|
|
}
|
|
|
|
func TestConfigDir(t *testing.T) {
|
|
p := Detect()
|
|
dir := p.ConfigDir()
|
|
if dir == "" {
|
|
t.Error("ConfigDir should not be empty")
|
|
}
|
|
}
|
|
|
|
func TestCacheDir(t *testing.T) {
|
|
p := Detect()
|
|
dir := p.CacheDir()
|
|
if dir == "" {
|
|
t.Error("CacheDir should not be empty")
|
|
}
|
|
}
|
|
|
|
func TestSummary(t *testing.T) {
|
|
p := Detect()
|
|
s := p.Summary()
|
|
if s == "" {
|
|
t.Error("Summary should not be empty")
|
|
}
|
|
// Should contain the OS name
|
|
if len(s) < 3 {
|
|
t.Errorf("Summary too short: %s", s)
|
|
}
|
|
}
|
|
|
|
func TestDefaultNATSURL(t *testing.T) {
|
|
p := Detect()
|
|
url := p.DefaultNATSURL()
|
|
if url != "nats://localhost:4222" {
|
|
t.Errorf("expected nats://localhost:4222, got %s", url)
|
|
}
|
|
}
|