2021-08-23 09:14:53 -04:00
|
|
|
//go:build linux
|
2021-05-25 19:48:54 -04:00
|
|
|
// +build linux
|
|
|
|
|
2016-02-16 22:15:18 -05:00
|
|
|
package ipvlan
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-04-05 20:24:47 -04:00
|
|
|
"github.com/docker/docker/libnetwork/driverapi"
|
2021-05-27 20:15:56 -04:00
|
|
|
"github.com/docker/docker/pkg/plugingetter"
|
2016-02-16 22:15:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
const testNetworkType = "ipvlan"
|
|
|
|
|
|
|
|
type driverTester struct {
|
|
|
|
t *testing.T
|
|
|
|
d *driver
|
|
|
|
}
|
|
|
|
|
2016-10-07 14:58:10 -04:00
|
|
|
func (dt *driverTester) GetPluginGetter() plugingetter.PluginGetter {
|
2016-09-27 16:54:25 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-02-16 22:15:18 -05:00
|
|
|
func (dt *driverTester) RegisterDriver(name string, drv driverapi.Driver,
|
|
|
|
cap driverapi.Capability) error {
|
|
|
|
if name != testNetworkType {
|
|
|
|
dt.t.Fatalf("Expected driver register name to be %q. Instead got %q",
|
|
|
|
testNetworkType, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := drv.(*driver); !ok {
|
|
|
|
dt.t.Fatalf("Expected driver type to be %T. Instead got %T",
|
|
|
|
&driver{}, drv)
|
|
|
|
}
|
|
|
|
|
|
|
|
dt.d = drv.(*driver)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIpvlanInit(t *testing.T) {
|
|
|
|
if err := Init(&driverTester{t: t}, nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIpvlanNilConfig(t *testing.T) {
|
|
|
|
dt := &driverTester{t: t}
|
|
|
|
if err := Init(dt, nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := dt.d.initStore(nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIpvlanType(t *testing.T) {
|
|
|
|
dt := &driverTester{t: t}
|
|
|
|
if err := Init(dt, nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if dt.d.Type() != testNetworkType {
|
|
|
|
t.Fatalf("Expected Type() to return %q. Instead got %q", testNetworkType,
|
|
|
|
dt.d.Type())
|
|
|
|
}
|
|
|
|
}
|