func (*readSeriesSuite) TestReadSeries(c *gc.C) { d := c.MkDir() f := filepath.Join(d, "foo") for i, t := range readSeriesTests { c.Logf("test %d", i) err := ioutil.WriteFile(f, []byte(t.contents), 0666) c.Assert(err, gc.IsNil) c.Assert(version.ReadSeries(f), gc.Equals, t.series) } }
func (s *readSeriesSuite) TestReadSeries(c *gc.C) { d := c.MkDir() f := filepath.Join(d, "foo") s.PatchValue(version.OSReleaseFile, f) for i, t := range readSeriesTests { c.Logf("test %d", i) err := ioutil.WriteFile(f, []byte(t.contents), 0666) c.Assert(err, jc.ErrorIsNil) series, err := version.ReadSeries() if t.err == "" { c.Assert(err, jc.ErrorIsNil) } else { c.Assert(err, gc.ErrorMatches, t.err) } c.Assert(series, gc.Equals, t.series) } }
func (s *linuxVersionSuite) TestOSVersion(c *gc.C) { // Set up fake /etc/os-release file from the future. d := c.MkDir() release := filepath.Join(d, "future-release") s.PatchValue(version.OSReleaseFile, release) err := ioutil.WriteFile(release, []byte(futureReleaseFileContents), 0666) c.Assert(err, jc.ErrorIsNil) // Set up fake /usr/share/distro-info/ubuntu.csv, also from the future. distroInfo := filepath.Join(d, "ubuntu.csv") err = ioutil.WriteFile(distroInfo, []byte(distroInfoContents), 0644) c.Assert(err, jc.ErrorIsNil) s.PatchValue(version.DistroInfo, distroInfo) // Ensure the future series can be read even though Juju doesn't // know about it. version, err := version.ReadSeries() c.Assert(err, jc.ErrorIsNil) c.Assert(version, gc.Equals, "spock") }