github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/version/supportedseries_linux_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package version_test 5 6 import ( 7 "io/ioutil" 8 "path/filepath" 9 "sort" 10 11 jc "github.com/juju/testing/checkers" 12 gc "gopkg.in/check.v1" 13 14 "github.com/juju/juju/version" 15 ) 16 17 func (s *supportedSeriesSuite) TestSeriesVersion(c *gc.C) { 18 // There is no distro-info on Windows or CentOS. 19 if version.Current.OS != version.Ubuntu { 20 c.Skip("This test is only relevant on Ubuntu.") 21 } 22 vers, err := version.SeriesVersion("precise") 23 if err != nil && err.Error() == `invalid series "precise"` { 24 c.Fatalf(`Unable to lookup series "precise", you may need to: apt-get install distro-info`) 25 } 26 c.Assert(err, jc.ErrorIsNil) 27 c.Assert(vers, gc.Equals, "12.04") 28 } 29 30 func (s *supportedSeriesSuite) TestSupportedSeries(c *gc.C) { 31 d := c.MkDir() 32 filename := filepath.Join(d, "ubuntu.csv") 33 err := ioutil.WriteFile(filename, []byte(distInfoData), 0644) 34 c.Assert(err, jc.ErrorIsNil) 35 s.PatchValue(version.DistroInfo, filename) 36 37 expectedSeries := []string{"precise", "quantal", "raring", "saucy"} 38 series := version.SupportedSeries() 39 sort.Strings(series) 40 c.Assert(series, gc.DeepEquals, expectedSeries) 41 } 42 43 const distInfoData = `version,codename,series,created,release,eol,eol-server 44 4.10,Warty Warthog,warty,2004-03-05,2004-10-20,2006-04-30 45 5.04,Hoary Hedgehog,hoary,2004-10-20,2005-04-08,2006-10-31 46 5.10,Breezy Badger,breezy,2005-04-08,2005-10-12,2007-04-13 47 6.06 LTS,Dapper Drake,dapper,2005-10-12,2006-06-01,2009-07-14,2011-06-01 48 6.10,Edgy Eft,edgy,2006-06-01,2006-10-26,2008-04-25 49 7.04,Feisty Fawn,feisty,2006-10-26,2007-04-19,2008-10-19 50 7.10,Gutsy Gibbon,gutsy,2007-04-19,2007-10-18,2009-04-18 51 8.04 LTS,Hardy Heron,hardy,2007-10-18,2008-04-24,2011-05-12,2013-05-09 52 8.10,Intrepid Ibex,intrepid,2008-04-24,2008-10-30,2010-04-30 53 9.04,Jaunty Jackalope,jaunty,2008-10-30,2009-04-23,2010-10-23 54 9.10,Karmic Koala,karmic,2009-04-23,2009-10-29,2011-04-29 55 10.04 LTS,Lucid Lynx,lucid,2009-10-29,2010-04-29,2013-05-09,2015-04-29 56 10.10,Maverick Meerkat,maverick,2010-04-29,2010-10-10,2012-04-10 57 11.04,Natty Narwhal,natty,2010-10-10,2011-04-28,2012-10-28 58 11.10,Oneiric Ocelot,oneiric,2011-04-28,2011-10-13,2013-05-09 59 12.04 LTS,Precise Pangolin,precise,2011-10-13,2012-04-26,2017-04-26 60 12.10,Quantal Quetzal,quantal,2012-04-26,2012-10-18,2014-04-18 61 13.04,Raring Ringtail,raring,2012-10-18,2013-04-25,2014-01-27 62 13.10,Saucy Salamander,saucy,2013-04-25,2013-10-17,2014-07-17 63 `