feat(internal): add platform detection and auth packages
- internal/platform: cross-platform path detection, 6 tests - internal/auth: JWT generation/validation + bcrypt, 8 tests - 89 total tests, build + vet clean
This commit is contained in:
1 parent
ca106f71ae
commit
aee8db9b3f
7 files changed
+444
-1
No files matched your search
@@ -0,0 +1,64 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user