Replaced explicit test hook method with type assertion
This commit is contained in:
Родитель
40af7bbc66
Коммит
3d665c42bc
|
@ -26,7 +26,6 @@ type ipamPlugin struct {
|
|||
type IpamPlugin interface {
|
||||
Start(chan error) error
|
||||
Stop()
|
||||
GetListener() *core.Listener
|
||||
}
|
||||
|
||||
// Creates a new IpamPlugin object.
|
||||
|
@ -80,11 +79,6 @@ func (plugin *ipamPlugin) Stop() {
|
|||
log.Printf("%s: Plugin stopped.\n", plugin.name)
|
||||
}
|
||||
|
||||
// Returns the listener for the plugin.
|
||||
func (plugin *ipamPlugin) GetListener() *core.Listener {
|
||||
return plugin.listener
|
||||
}
|
||||
|
||||
type activateResponse struct {
|
||||
Implements []string
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ func TestMain(m *testing.M) {
|
|||
return
|
||||
}
|
||||
|
||||
mux = plugin.GetListener().GetMux()
|
||||
// Get the internal http mux as test hook.
|
||||
mux = plugin.(*ipamPlugin).listener.GetMux()
|
||||
|
||||
// Run tests.
|
||||
exitCode := m.Run()
|
||||
|
|
|
@ -28,7 +28,6 @@ type netPlugin struct {
|
|||
type NetPlugin interface {
|
||||
Start(chan error) error
|
||||
Stop()
|
||||
GetListener() *core.Listener
|
||||
}
|
||||
|
||||
// Creates a new NetPlugin object.
|
||||
|
@ -85,11 +84,6 @@ func (plugin *netPlugin) Stop() {
|
|||
log.Printf("%s: Plugin stopped.\n", plugin.name)
|
||||
}
|
||||
|
||||
// Returns the listener for the plugin.
|
||||
func (plugin *netPlugin) GetListener() *core.Listener {
|
||||
return plugin.listener
|
||||
}
|
||||
|
||||
func (plugin *netPlugin) networkExists(networkID string) bool {
|
||||
if plugin.networks[networkID] != nil {
|
||||
return true
|
||||
|
|
|
@ -35,7 +35,8 @@ func TestMain(m *testing.M) {
|
|||
return
|
||||
}
|
||||
|
||||
mux = plugin.GetListener().GetMux()
|
||||
// Get the internal http mux as test hook.
|
||||
mux = plugin.(*netPlugin).listener.GetMux()
|
||||
|
||||
// Run tests.
|
||||
exitCode := m.Run()
|
||||
|
|
Загрузка…
Ссылка в новой задаче