Permalink
Browse files

test fixes

  • Loading branch information...
1 parent c350f44 commit e39f89641deac2069aff820cb35ac6e4fbf482d6 @mvo5 mvo5 committed Jul 14, 2016
@@ -54,6 +54,6 @@ func (b *MockBootloader) Name() string {
return b.name
}
-func (b *MockBootloader) configFile() string {
+func (b *MockBootloader) ConfigFile() string {
return "/boot/mock/mock.cfg"
}
@@ -63,19 +63,19 @@ type Bootloader interface {
Name() string
// configFile returns the name of the config file
- configFile() string
+ ConfigFile() string
}
// InstallBootConfig install the bootloader config from the gadget
// snap dir into the right place
func InstallBootConfig(gadgetDir string) error {
for _, bl := range []Bootloader{&grub{}, &uboot{}} {
- fn, err := find(gadgetDir, filepath.Base(bl.configFile()))
+ fn, err := find(gadgetDir, filepath.Base(bl.ConfigFile()))
if err != nil {
continue
}
- dst := bl.configFile()
+ dst := bl.ConfigFile()
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
return err
}
@@ -59,7 +59,7 @@ func (b *mockBootloader) SetBootVar(name, value string) error {
b.bootVars[name] = value
return nil
}
-func (b *mockBootloader) configFile() string {
+func (b *mockBootloader) ConfigFile() string {
return "/boot/mocky/mocky.env"
}
View
@@ -40,7 +40,7 @@ type grub struct {
// newGrub create a new Grub bootloader object
func newGrub() Bootloader {
g := &grub{}
- if !osutil.FileExists(g.configFile()) {
+ if !osutil.FileExists(g.ConfigFile()) {
return nil
}
@@ -55,7 +55,7 @@ func (g *grub) Dir() string {
return filepath.Join(dirs.GlobalRootDir, "/boot/grub")
}
-func (g *grub) configFile() string {
+func (g *grub) ConfigFile() string {
return filepath.Join(g.Dir(), "grub.cfg")
}
@@ -42,7 +42,7 @@ func mockGrubFile(c *C, newPath string, mode os.FileMode) {
func (s *PartitionTestSuite) makeFakeGrubEnv(c *C) {
// these files just needs to exist
g := &grub{}
- mockGrubFile(c, g.configFile(), 0644)
+ mockGrubFile(c, g.ConfigFile(), 0644)
mockGrubFile(c, g.envFile(), 0644)
}
View
@@ -49,7 +49,7 @@ func (u *uboot) Dir() string {
return filepath.Join(dirs.GlobalRootDir, "/boot/uboot")
}
-func (u *uboot) configFile() string {
+func (u *uboot) ConfigFile() string {
return u.envFile()
}
@@ -22,6 +22,7 @@ import (
"path/filepath"
"testing"
+ "github.com/snapcore/snapd/boot/boottest"
"github.com/snapcore/snapd/partition"
. "gopkg.in/check.v1"
@@ -30,27 +31,10 @@ import (
// Hook up gocheck into the "go test" runner
func Test(t *testing.T) { TestingT(t) }
-type mockBootloader struct {
- dir string
-}
-
-func (b *mockBootloader) Name() string {
- return "mocky"
-}
-func (b *mockBootloader) Dir() string {
- return b.dir
-}
-func (b *mockBootloader) SetBootVar(key, value string) error {
- return nil
-}
-func (b *mockBootloader) GetBootVar(key string) (string, error) {
- return "", nil
-}
-
type ProvisioningTestSuite struct {
mockYamlFile string
- bootloader *mockBootloader
+ bootloader *boottest.MockBootloader
}
var _ = Suite(&ProvisioningTestSuite{})
@@ -93,8 +77,8 @@ options:
var garbageData = `Fooled you!?`
func (ts *ProvisioningTestSuite) SetUpTest(c *C) {
- ts.bootloader = &mockBootloader{dir: c.MkDir()}
- ts.mockYamlFile = filepath.Join(ts.bootloader.dir, "install.yaml")
+ ts.bootloader = boottest.NewMockBootloader("mock", c.MkDir())
+ ts.mockYamlFile = filepath.Join(ts.bootloader.Dir(), "install.yaml")
findBootloader = func() (partition.Bootloader, error) {
return ts.bootloader, nil
@@ -141,11 +125,6 @@ func (ts *ProvisioningTestSuite) TestParseInstallYamlData(c *C) {
c.Check(err, Not(Equals), nil)
}
-func (ts *ProvisioningTestSuite) TestInDeveloperModeEmpty(c *C) {
- ts.bootloader.dir = ""
- c.Assert(InDeveloperMode(), Equals, false)
-}
-
func (ts *ProvisioningTestSuite) TestInDeveloperModeWithDevModeOn(c *C) {
err := ioutil.WriteFile(ts.mockYamlFile, []byte(`
options:

0 comments on commit e39f896

Please sign in to comment.