1
// Copyright 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
11
jc "github.com/juju/testing/checkers"
12
gc "gopkg.in/check.v1"
14
"github.com/juju/utils/os"
15
"github.com/juju/utils/series"
18
func (s *supportedSeriesSuite) TestSeriesVersion(c *gc.C) {
19
// There is no distro-info on Windows or CentOS.
20
if os.HostOS() != os.Ubuntu {
21
c.Skip("This test is only relevant on Ubuntu.")
23
vers, err := series.SeriesVersion("precise")
24
if err != nil && err.Error() == `invalid series "precise"` {
25
c.Fatalf(`Unable to lookup series "precise", you may need to: apt-get install distro-info`)
27
c.Assert(err, jc.ErrorIsNil)
28
c.Assert(vers, gc.Equals, "12.04")
31
func (s *supportedSeriesSuite) TestSupportedSeries(c *gc.C) {
33
filename := filepath.Join(d, "ubuntu.csv")
34
err := ioutil.WriteFile(filename, []byte(distInfoData), 0644)
35
c.Assert(err, jc.ErrorIsNil)
36
s.PatchValue(series.DistroInfo, filename)
38
expectedSeries := []string{"precise", "quantal", "raring", "saucy"}
39
series := series.SupportedSeries()
41
c.Assert(series, gc.DeepEquals, expectedSeries)
44
func (s *supportedSeriesSuite) TestUpdateSeriesVersions(c *gc.C) {
46
filename := filepath.Join(d, "ubuntu.csv")
47
err := ioutil.WriteFile(filename, []byte(distInfoData), 0644)
48
c.Assert(err, jc.ErrorIsNil)
49
s.PatchValue(series.DistroInfo, filename)
51
expectedSeries := []string{"precise", "quantal", "raring", "saucy"}
52
checkSeries := func() {
53
series := series.SupportedSeries()
55
c.Assert(series, gc.DeepEquals, expectedSeries)
59
// Updating the file does not normally trigger an update;
60
// we only refresh automatically one time. After that, we
61
// must explicitly refresh.
62
err = ioutil.WriteFile(filename, []byte(distInfoData2), 0644)
63
c.Assert(err, jc.ErrorIsNil)
66
expectedSeries = append(expectedSeries, "trusty")
67
series.UpdateSeriesVersions()
71
const distInfoData = `version,codename,series,created,release,eol,eol-server
72
4.10,Warty Warthog,warty,2004-03-05,2004-10-20,2006-04-30
73
5.04,Hoary Hedgehog,hoary,2004-10-20,2005-04-08,2006-10-31
74
5.10,Breezy Badger,breezy,2005-04-08,2005-10-12,2007-04-13
75
6.06 LTS,Dapper Drake,dapper,2005-10-12,2006-06-01,2009-07-14,2011-06-01
76
6.10,Edgy Eft,edgy,2006-06-01,2006-10-26,2008-04-25
77
7.04,Feisty Fawn,feisty,2006-10-26,2007-04-19,2008-10-19
78
7.10,Gutsy Gibbon,gutsy,2007-04-19,2007-10-18,2009-04-18
79
8.04 LTS,Hardy Heron,hardy,2007-10-18,2008-04-24,2011-05-12,2013-05-09
80
8.10,Intrepid Ibex,intrepid,2008-04-24,2008-10-30,2010-04-30
81
9.04,Jaunty Jackalope,jaunty,2008-10-30,2009-04-23,2010-10-23
82
9.10,Karmic Koala,karmic,2009-04-23,2009-10-29,2011-04-29
83
10.04 LTS,Lucid Lynx,lucid,2009-10-29,2010-04-29,2013-05-09,2015-04-29
84
10.10,Maverick Meerkat,maverick,2010-04-29,2010-10-10,2012-04-10
85
11.04,Natty Narwhal,natty,2010-10-10,2011-04-28,2012-10-28
86
11.10,Oneiric Ocelot,oneiric,2011-04-28,2011-10-13,2013-05-09
87
12.04 LTS,Precise Pangolin,precise,2011-10-13,2012-04-26,2017-04-26
88
12.10,Quantal Quetzal,quantal,2012-04-26,2012-10-18,2014-04-18
89
13.04,Raring Ringtail,raring,2012-10-18,2013-04-25,2014-01-27
90
13.10,Saucy Salamander,saucy,2013-04-25,2013-10-17,2014-07-17
93
const distInfoData2 = distInfoData + `
94
14.04 LTS,Trusty Tahr,trusty,2013-10-17,2014-04-17,2019-04-17