github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/os/os_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the LGPLv3, see LICENCE file for details. 3 4 package os 5 6 import ( 7 "runtime" 8 9 gc "gopkg.in/check.v1" 10 11 "github.com/juju/juju/core/os/ostype" 12 ) 13 14 type osSuite struct { 15 } 16 17 var _ = gc.Suite(&osSuite{}) 18 19 func (s *osSuite) TestHostOS(c *gc.C) { 20 os := HostOS() 21 switch runtime.GOOS { 22 case "windows": 23 c.Assert(os, gc.Equals, ostype.Windows) 24 case "darwin": 25 c.Assert(os, gc.Equals, ostype.OSX) 26 case "linux": 27 // TODO(mjs) - this should really do more by patching out 28 // osReleaseFile and testing the corner cases. 29 switch os { 30 case ostype.Ubuntu, ostype.CentOS, ostype.GenericLinux: 31 default: 32 c.Fatalf("unknown linux version: %v", os) 33 } 34 default: 35 c.Fatalf("unsupported operating system: %v", runtime.GOOS) 36 } 37 }