package manifest import ( "runtime" "testing" ) func TestRuleOsName(t *testing.T) { macos := Rule{Action: ActionAllow} macos.Os.Name = "osx" if ok, _ := macos.Check(); runtime.GOOS != "darwin" && ok { t.Fatal("Rule.Os.Name == 'osx', but is true on ", runtime.GOOS) } linux := Rule{Action: ActionAllow} linux.Os.Name = "linux" if ok, _ := linux.Check(); runtime.GOOS != "linux" && ok { t.Fatalf("Rule.Os.Name == '%s', but is true on %s\n", linux.Os.Name, runtime.GOOS) } windows := Rule{Action: ActionAllow} windows.Os.Name = "windows" if ok, _ := windows.Check(); runtime.GOOS != "windows" && ok { t.Fatalf("Rule.Os.Name == '%s', but is true on %s\n", windows.Os.Name, runtime.GOOS) } x86 := Rule{Action: ActionAllow} x86.Os.Arch = "x86" if ok, _ := x86.Check(); runtime.GOARCH != "386" && ok { t.Fatalf("Rule.Os.Arch == '%s', but is true on %s\n", windows.Os.Arch, runtime.GOOS) } emptyAllow := Rule{Action: ActionAllow} if ok, _ := emptyAllow.Check(); !ok { t.Fatalf("An empty allow rule must return true\n") } disOsx := Rule{Action: ActionDisallow} disOsx.Os.Name = "osx" if ok, _ := disOsx.Check(); runtime.GOOS != "darwin" && !ok { t.Fatalf("A disallow rule for OSX must return false, and true for other OSes\n") } }