feat(platform): detect distro, WSL, and architecture
This commit is contained in:
45
internal/platform/platform_test.go
Normal file
45
internal/platform/platform_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseDistroArch(t *testing.T) {
|
||||
osRelease := `NAME="Arch Linux"
|
||||
ID=arch
|
||||
ID_LIKE=archlinux
|
||||
`
|
||||
if got := parseDistro(strings.NewReader(osRelease)); got != DistroArch {
|
||||
t.Fatalf("got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDistroUbuntu(t *testing.T) {
|
||||
osRelease := `NAME="Ubuntu"
|
||||
ID=ubuntu
|
||||
`
|
||||
if got := parseDistro(strings.NewReader(osRelease)); got != DistroUnknown {
|
||||
t.Fatalf("got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDistroQuoted(t *testing.T) {
|
||||
osRelease := `ID="arch"
|
||||
`
|
||||
if got := parseDistro(strings.NewReader(osRelease)); got != DistroArch {
|
||||
t.Fatalf("got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectReturnsArch(t *testing.T) {
|
||||
p, err := Detect()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Arch == "" {
|
||||
t.Fatal("arch is empty")
|
||||
}
|
||||
// We don't assert Distro here because the test host may not be Arch.
|
||||
// The parse-level tests above cover that logic.
|
||||
}
|
||||
Reference in New Issue
Block a user