github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/base/supportedseries_linux_test.go (about)

     1  // Copyright 2021 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package base
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/juju/collections/transform"
    10  	jujuos "github.com/juju/os/v2"
    11  	jujuseries "github.com/juju/os/v2/series"
    12  	"github.com/juju/testing"
    13  	jc "github.com/juju/testing/checkers"
    14  	gc "gopkg.in/check.v1"
    15  )
    16  
    17  type SupportedSeriesLinuxSuite struct {
    18  	testing.IsolationSuite
    19  }
    20  
    21  var _ = gc.Suite(&SupportedSeriesLinuxSuite{})
    22  
    23  func (s *SupportedSeriesLinuxSuite) SetUpTest(c *gc.C) {
    24  	s.IsolationSuite.SetUpTest(c)
    25  	s.PatchValue(&LocalSeriesVersionInfo, func() (jujuos.OSType, map[string]jujuseries.SeriesVersionInfo, error) {
    26  		return jujuos.Ubuntu, map[string]jujuseries.SeriesVersionInfo{
    27  			"hairy": {},
    28  		}, nil
    29  	})
    30  }
    31  
    32  func (s *SupportedSeriesLinuxSuite) TestWorkloadBases(c *gc.C) {
    33  	tmpFile, close := makeTempFile(c, distroInfoContents)
    34  	defer close()
    35  
    36  	s.PatchValue(&UbuntuDistroInfo, tmpFile.Name())
    37  
    38  	bases, err := WorkloadBases(time.Time{}, Base{}, "")
    39  	c.Assert(err, jc.ErrorIsNil)
    40  	c.Assert(bases, gc.DeepEquals, transform.Slice([]string{
    41  		"centos@7", "centos@9", "genericlinux@genericlinux", "kubernetes@kubernetes",
    42  		"ubuntu@20.04", "ubuntu@22.04", "ubuntu@24.04",
    43  	}, MustParseBaseFromString))
    44  }