github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/version/current_test.go (about) 1 // Copyright 2012, 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package version 5 6 import ( 7 "os/exec" 8 "runtime" 9 10 "github.com/juju/utils/os" 11 "github.com/juju/utils/series" 12 gc "gopkg.in/check.v1" 13 ) 14 15 type CurrentSuite struct{} 16 17 var _ = gc.Suite(&CurrentSuite{}) 18 19 func (*CurrentSuite) TestCurrentSeries(c *gc.C) { 20 s := series.HostSeries() 21 if s == "unknown" { 22 s = "n/a" 23 } 24 out, err := exec.Command("lsb_release", "-c").CombinedOutput() 25 26 if err != nil { 27 // If the command fails (for instance if we're running on some other 28 // platform) then CurrentSeries should be unknown. 29 switch runtime.GOOS { 30 case "darwin": 31 c.Check(s, gc.Matches, `mavericks|mountainlion|lion|snowleopard`) 32 case "windows": 33 c.Check(s, gc.Matches, `win2012hvr2|win2012hv|win2012|win2012r2|win8|win81|win7`) 34 default: 35 current_os, err := series.GetOSFromSeries(s) 36 c.Assert(err, gc.IsNil) 37 if s != "n/a" { 38 // There is no lsb_release command on CentOS. 39 if current_os == os.CentOS { 40 c.Check(s, gc.Matches, `centos7`) 41 } 42 } 43 } 44 } else { 45 c.Assert(string(out), gc.Equals, "Codename:\t"+s+"\n") 46 } 47 }