func (s *windowsSeriesSuite) TestReadSeries(c *gc.C) { for _, value := range versionTests { k, err := registry.OpenKey(registry.LOCAL_MACHINE, *series.CurrentVersionKey, registry.ALL_ACCESS) c.Assert(err, jc.ErrorIsNil) err = k.SetStringValue("ProductName", value.version) c.Assert(err, jc.ErrorIsNil) err = k.Close() c.Assert(err, jc.ErrorIsNil) ver, err := series.ReadSeries() c.Assert(err, jc.ErrorIsNil) c.Assert(ver, gc.Equals, value.want) } }
func (s *readSeriesSuite) TestReadSeries(c *gc.C) { d := c.MkDir() f := filepath.Join(d, "foo") s.PatchValue(series.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 := series.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(series.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(series.DistroInfo, distroInfo) // Ensure the future series can be read even though Juju doesn't // know about it. version, err := series.ReadSeries() c.Assert(err, jc.ErrorIsNil) c.Assert(version, gc.Equals, "spock") }