-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathos_test.go
63 lines (53 loc) · 1.64 KB
/
os_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package os
import (
"runtime"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
)
type osSuite struct {
}
var _ = gc.Suite(&osSuite{})
func (s *osSuite) TestHostOS(c *gc.C) {
os := HostOS()
switch runtime.GOOS {
case "windows":
c.Assert(os, gc.Equals, Windows)
case "darwin":
c.Assert(os, gc.Equals, OSX)
case "linux":
// TODO(mjs) - this should really do more by patching out
// osReleaseFile and testing the corner cases.
switch os {
case Ubuntu, CentOS, GenericLinux:
case OpenSUSE:
c.Assert(os, gc.Equals, OpenSUSE)
default:
c.Fatalf("unknown linux version: %v", os)
}
default:
c.Fatalf("unsupported operating system: %v", runtime.GOOS)
}
}
func (s *osSuite) TestEquivalentTo(c *gc.C) {
c.Check(Ubuntu.EquivalentTo(CentOS), jc.IsTrue)
c.Check(Ubuntu.EquivalentTo(GenericLinux), jc.IsTrue)
c.Check(Ubuntu.EquivalentTo(OpenSUSE), jc.IsTrue)
c.Check(GenericLinux.EquivalentTo(Ubuntu), jc.IsTrue)
c.Check(GenericLinux.EquivalentTo(OpenSUSE), jc.IsTrue)
c.Check(CentOS.EquivalentTo(CentOS), jc.IsTrue)
c.Check(CentOS.EquivalentTo(OpenSUSE), jc.IsTrue)
c.Check(OSX.EquivalentTo(Ubuntu), jc.IsFalse)
c.Check(OSX.EquivalentTo(Windows), jc.IsFalse)
c.Check(GenericLinux.EquivalentTo(OSX), jc.IsFalse)
}
func (s *osSuite) TestIsLinux(c *gc.C) {
c.Check(Ubuntu.IsLinux(), jc.IsTrue)
c.Check(CentOS.IsLinux(), jc.IsTrue)
c.Check(GenericLinux.IsLinux(), jc.IsTrue)
c.Check(OpenSUSE.IsLinux(), jc.IsTrue)
c.Check(OSX.IsLinux(), jc.IsFalse)
c.Check(Windows.IsLinux(), jc.IsFalse)
c.Check(Unknown.IsLinux(), jc.IsFalse)
}