~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/os/os_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "runtime"
8
8
 
 
9
        jc "github.com/juju/testing/checkers"
9
10
        gc "gopkg.in/check.v1"
10
11
)
11
12
 
22
23
        case "darwin":
23
24
                c.Assert(os, gc.Equals, OSX)
24
25
        case "linux":
25
 
                if os != Ubuntu && os != CentOS && os != Arch {
 
26
                // TODO(mjs) - this should really do more by patching out
 
27
                // osReleaseFile and testing the corner cases.
 
28
                switch os {
 
29
                case Ubuntu, CentOS, GenericLinux:
 
30
                default:
26
31
                        c.Fatalf("unknown linux version: %v", os)
27
32
                }
28
33
        default:
29
34
                c.Fatalf("unsupported operating system: %v", runtime.GOOS)
30
35
        }
31
36
}
 
37
 
 
38
func (s *osSuite) TestEquivalentTo(c *gc.C) {
 
39
        c.Check(Ubuntu.EquivalentTo(CentOS), jc.IsTrue)
 
40
        c.Check(Ubuntu.EquivalentTo(GenericLinux), jc.IsTrue)
 
41
        c.Check(GenericLinux.EquivalentTo(Ubuntu), jc.IsTrue)
 
42
        c.Check(CentOS.EquivalentTo(CentOS), jc.IsTrue)
 
43
 
 
44
        c.Check(OSX.EquivalentTo(Ubuntu), jc.IsFalse)
 
45
        c.Check(OSX.EquivalentTo(Windows), jc.IsFalse)
 
46
        c.Check(GenericLinux.EquivalentTo(OSX), jc.IsFalse)
 
47
}
 
48
 
 
49
func (s *osSuite) TestIsLinux(c *gc.C) {
 
50
        c.Check(Ubuntu.IsLinux(), jc.IsTrue)
 
51
        c.Check(CentOS.IsLinux(), jc.IsTrue)
 
52
        c.Check(GenericLinux.IsLinux(), jc.IsTrue)
 
53
 
 
54
        c.Check(OSX.IsLinux(), jc.IsFalse)
 
55
        c.Check(Windows.IsLinux(), jc.IsFalse)
 
56
        c.Check(Unknown.IsLinux(), jc.IsFalse)
 
57
}