diff --git a/overlord/hookstate/ctlcmd/export_test.go b/overlord/hookstate/ctlcmd/export_test.go index 852c85f6a88..b59b04d32bc 100644 --- a/overlord/hookstate/ctlcmd/export_test.go +++ b/overlord/hookstate/ctlcmd/export_test.go @@ -39,15 +39,15 @@ const ( var ( AttributesTask = attributesTask - KmodEnsureConnection = kmodEnsureConnection - KmodMatchConnection = kmodMatchConnection + KmodCheckConnection = kmodCheckConnection + KmodMatchConnection = kmodMatchConnection ) type KmodCommand = kmodCommand -func MockKmodEnsureConnection(f func(*hookstate.Context, string, []string) error) (restore func()) { - r := testutil.Backup(&kmodEnsureConnection) - kmodEnsureConnection = f +func MockKmodCheckConnection(f func(*hookstate.Context, string, []string) error) (restore func()) { + r := testutil.Backup(&kmodCheckConnection) + kmodCheckConnection = f return r } diff --git a/overlord/hookstate/ctlcmd/kmod.go b/overlord/hookstate/ctlcmd/kmod.go index 1d495057ad9..ed841bb27e1 100644 --- a/overlord/hookstate/ctlcmd/kmod.go +++ b/overlord/hookstate/ctlcmd/kmod.go @@ -74,7 +74,7 @@ func (k *KModInsertCmd) Execute([]string) error { return err } - if err := kmodEnsureConnection(context, k.Positional.Module, k.Positional.Options); err != nil { + if err := kmodCheckConnection(context, k.Positional.Module, k.Positional.Options); err != nil { return fmt.Errorf("cannot load module %q: %v", k.Positional.Module, err) } @@ -98,7 +98,7 @@ func (k *KModRemoveCmd) Execute([]string) error { return err } - if err := kmodEnsureConnection(context, k.Positional.Module, []string{}); err != nil { + if err := kmodCheckConnection(context, k.Positional.Module, []string{}); err != nil { return fmt.Errorf("cannot unload module %q: %v", k.Positional.Module, err) } @@ -133,10 +133,10 @@ func kmodMatchConnection(attributes map[string]interface{}, moduleName string, m return true } -// kmodFindConnections walks through the established connections to find one which +// kmodCheckConnection walks through the established connections to find one which // is compatible with a kmod operation on the given moduleName and // moduleOptions. Returns an error if not found. -var kmodEnsureConnection = func(context *hookstate.Context, moduleName string, moduleOptions []string) (err error) { +var kmodCheckConnection = func(context *hookstate.Context, moduleName string, moduleOptions []string) (err error) { snapName := context.InstanceName() st := context.State() diff --git a/overlord/hookstate/ctlcmd/kmod_test.go b/overlord/hookstate/ctlcmd/kmod_test.go index ae763e5fd5b..1dae8d6f4a3 100644 --- a/overlord/hookstate/ctlcmd/kmod_test.go +++ b/overlord/hookstate/ctlcmd/kmod_test.go @@ -140,7 +140,7 @@ func (s *kmodSuite) TestFindConnectionBadConnection(c *C) { ctx, err := hookstate.NewContext(task, state, setup, s.mockHandler, "") c.Assert(err, IsNil) - err = ctlcmd.KmodEnsureConnection(ctx, "module1", []string{"one", "two"}) + err = ctlcmd.KmodCheckConnection(ctx, "module1", []string{"one", "two"}) c.Assert(err, ErrorMatches, `.*internal error: cannot get connections: .*`) } @@ -176,14 +176,14 @@ func (s *kmodSuite) TestFindConnectionMissingProperPlug(c *C) { s.state.Set("conns", connections) s.state.Unlock() - err := ctlcmd.KmodEnsureConnection(s.mockContext, "module3", []string{"opt1=v1"}) + err := ctlcmd.KmodCheckConnection(s.mockContext, "module3", []string{"opt1=v1"}) c.Check(err, ErrorMatches, "required interface not connected") } func (s *kmodSuite) TestFindConnectionHappy(c *C) { s.injectSnapWithProperPlug(c) - err := ctlcmd.KmodEnsureConnection(s.mockContext, "module2", []string{"opt1=v1"}) + err := ctlcmd.KmodCheckConnection(s.mockContext, "module2", []string{"opt1=v1"}) c.Check(err, IsNil) } @@ -193,7 +193,7 @@ func (s *kmodSuite) TestInsertFailure(c *C) { var loadModuleError error var ensureConnectionError error - r1 := ctlcmd.MockKmodEnsureConnection(func(ctx *hookstate.Context, moduleName string, moduleOptions []string) error { + r1 := ctlcmd.MockKmodCheckConnection(func(ctx *hookstate.Context, moduleName string, moduleOptions []string) error { c.Check(moduleName, Equals, "moderr") c.Check(moduleOptions, DeepEquals, []string{"o1=v1", "o2=v2"}) return ensureConnectionError @@ -254,7 +254,7 @@ func (s *kmodSuite) TestRemoveFailure(c *C) { var loadModuleError error var ensureConnectionError error - r1 := ctlcmd.MockKmodEnsureConnection(func(ctx *hookstate.Context, moduleName string, moduleOptions []string) error { + r1 := ctlcmd.MockKmodCheckConnection(func(ctx *hookstate.Context, moduleName string, moduleOptions []string) error { c.Check(moduleName, Equals, "moderr") c.Check(moduleOptions, HasLen, 0) return ensureConnectionError