2021-02-02 12:05:47 +01:00
|
|
|
package platform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGood(t *testing.T) {
|
|
|
|
var expected bool
|
|
|
|
switch Name() {
|
2022-03-08 12:25:33 +01:00
|
|
|
case "android", "freebsd", "openbsd", "ios", "linux", "macos", "windows":
|
2021-02-02 12:05:47 +01:00
|
|
|
expected = true
|
|
|
|
}
|
|
|
|
if !expected {
|
|
|
|
t.Fatal("unexpected platform name")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-04 11:46:06 +02:00
|
|
|
func TestName(t *testing.T) {
|
2021-02-02 12:05:47 +01:00
|
|
|
var runtimevariables = []struct {
|
|
|
|
expected string
|
|
|
|
goos string
|
|
|
|
}{{
|
|
|
|
expected: "android",
|
|
|
|
goos: "android",
|
2021-08-20 14:00:06 +02:00
|
|
|
}, {
|
|
|
|
expected: "freebsd",
|
|
|
|
goos: "freebsd",
|
2022-03-08 12:25:33 +01:00
|
|
|
}, {
|
|
|
|
expected: "openbsd",
|
|
|
|
goos: "openbsd",
|
2021-02-02 12:05:47 +01:00
|
|
|
}, {
|
|
|
|
expected: "ios",
|
2021-06-04 11:46:06 +02:00
|
|
|
goos: "ios",
|
2021-02-02 12:05:47 +01:00
|
|
|
}, {
|
|
|
|
expected: "linux",
|
|
|
|
goos: "linux",
|
|
|
|
}, {
|
|
|
|
expected: "macos",
|
|
|
|
goos: "darwin",
|
|
|
|
}, {
|
|
|
|
expected: "unknown",
|
|
|
|
goos: "solaris",
|
|
|
|
}, {
|
|
|
|
expected: "windows",
|
|
|
|
goos: "windows",
|
|
|
|
}}
|
|
|
|
for _, v := range runtimevariables {
|
2021-06-04 11:46:06 +02:00
|
|
|
t.Run(fmt.Sprintf("with %s", v.goos), func(t *testing.T) {
|
|
|
|
if name(v.goos) != v.expected {
|
2021-02-02 12:05:47 +01:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|