func (*kernelVersionSuite) TestKernelToMajorVersionNotInt(c *gc.C) { majorVersion, err := version.KernelToMajor(func() (string, error) { return "a.b.c", nil }) c.Assert(err, gc.ErrorMatches, `strconv.ParseInt: parsing "a": invalid syntax`) c.Check(majorVersion, gc.Equals, 0) }
func (*kernelVersionSuite) TestKernelToMajorVersionNoDots(c *gc.C) { majorVersion, err := version.KernelToMajor(func() (string, error) { return "1234", nil }) c.Assert(err, gc.IsNil) c.Check(majorVersion, gc.Equals, 1234) }
func (*kernelVersionSuite) TestKernelToMajorVersionError(c *gc.C) { majorVersion, err := version.KernelToMajor(sysctlError) c.Assert(err, gc.ErrorMatches, "no such syscall") c.Check(majorVersion, gc.Equals, 0) }
func (*kernelVersionSuite) TestKernelToMajorVersion(c *gc.C) { majorVersion, err := version.KernelToMajor(sysctlMacOS10dot9dot2) c.Assert(err, gc.IsNil) c.Check(majorVersion, gc.Equals, 13) }