1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
// Copyright 2015 Canonical Ltd.
// Copyright 2015 Cloudbase Solutions SRL
// Licensed under the LGPLv3, see LICENCE file for details.
package config_test
import (
"fmt"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/packaging"
"github.com/juju/utils/packaging/config"
gc "gopkg.in/check.v1"
)
var _ = gc.Suite(&FunctionsSuite{})
type FunctionsSuite struct {
}
func (s *FunctionsSuite) TestSeriesRequiresCloudArchiveTools(c *gc.C) {
testedSeries := []string{
"precise",
"centos7",
"rogentos",
"debian",
"mint",
"makulu",
"rhel lol",
"opensuseleap",
}
for i, series := range testedSeries {
c.Logf("Test %d: series %s:", i+1, series)
res := config.SeriesRequiresCloudArchiveTools(series)
_, req := config.SeriesRequiringCloudTools[series]
c.Assert(res, gc.Equals, req)
}
}
func (s *FunctionsSuite) TestGetCloudArchiveSourceCentOS(c *gc.C) {
src, prefs := config.GetCloudArchiveSource("centos7")
c.Assert(src, gc.Equals, packaging.PackageSource{})
c.Assert(prefs, gc.Equals, packaging.PackagePreferences{})
}
func (s *FunctionsSuite) TestGetCloudArchiveSourceOpenSUSE(c *gc.C) {
src, prefs := config.GetCloudArchiveSource("opensuseleap")
c.Assert(src, gc.Equals, packaging.PackageSource{})
c.Assert(prefs, gc.Equals, packaging.PackagePreferences{})
}
func (s *FunctionsSuite) TestGetCloudArchiveSourceUbuntu(c *gc.C) {
expectedSrc := packaging.PackageSource{
URL: fmt.Sprintf("deb %s %s-updates/cloud-tools main", config.UbuntuCloudArchiveUrl, "precise"),
Key: config.UbuntuCloudArchiveSigningKey,
}
expectedPrefs := packaging.PackagePreferences{
Path: config.UbuntuCloudToolsPrefsPath,
Explanation: "Pin with lower priority, not to interfere with charms.",
Package: "*",
Pin: fmt.Sprintf("release n=%s-updates/cloud-tools", "precise"),
Priority: 400,
}
src, prefs := config.GetCloudArchiveSource("precise")
c.Assert(src, gc.Equals, expectedSrc)
c.Assert(prefs, gc.Equals, expectedPrefs)
}
func (s *FunctionsSuite) TestRequiresBackportsTrustyLXD(c *gc.C) {
requiresBackports := config.RequiresBackports("trusty", "lxd")
c.Assert(requiresBackports, jc.IsTrue)
}
|