ooni-probe-cli/internal/platform/platform_test.go
Simone Basso 4764d7f378
cleanup(platform): we don't need CGO anymore (#355)
* cleanup(platform): we don't need CGO anymore

Since go1.16, we have the `ios` port. So we can easily
disambiguate between ios and darwin.

This means we don't need to rely on CGO to correctly guess
whether we are on ios or darwin anymore.

So, now miniooni does not depend on a C compiler even
when you are not cross compiling.

* Update internal/platform/platform.go
2021-06-04 11:46:06 +02:00

50 lines
832 B
Go

package platform
import (
"fmt"
"testing"
)
func TestGood(t *testing.T) {
var expected bool
switch Name() {
case "android", "ios", "linux", "macos", "windows":
expected = true
}
if !expected {
t.Fatal("unexpected platform name")
}
}
func TestName(t *testing.T) {
var runtimevariables = []struct {
expected string
goos string
}{{
expected: "android",
goos: "android",
}, {
expected: "ios",
goos: "ios",
}, {
expected: "linux",
goos: "linux",
}, {
expected: "macos",
goos: "darwin",
}, {
expected: "unknown",
goos: "solaris",
}, {
expected: "windows",
goos: "windows",
}}
for _, v := range runtimevariables {
t.Run(fmt.Sprintf("with %s", v.goos), func(t *testing.T) {
if name(v.goos) != v.expected {
t.Fatal("unexpected results")
}
})
}
}