github.com/rogpeppe/juju@v0.0.0-20140613142852-6337964b789e/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_test 5 6 import ( 7 "os/exec" 8 "runtime" 9 10 gc "launchpad.net/gocheck" 11 12 "github.com/juju/juju/version" 13 ) 14 15 type CurrentSuite struct{} 16 17 var _ = gc.Suite(&CurrentSuite{}) 18 19 func (*CurrentSuite) TestCurrentSeries(c *gc.C) { 20 s := version.Current.Series 21 if s == "unknown" { 22 s = "n/a" 23 } 24 out, err := exec.Command("lsb_release", "-c").CombinedOutput() 25 if err != nil { 26 // If the command fails (for instance if we're running on some other 27 // platform) then CurrentSeries should be unknown. 28 switch runtime.GOOS { 29 case "darwin": 30 c.Check(s, gc.Matches, `mavericks|mountainlion|lion|snowleopard`) 31 default: 32 c.Assert(s, gc.Equals, "n/a") 33 } 34 } else { 35 c.Assert(string(out), gc.Equals, "Codename:\t"+s+"\n") 36 } 37 }