427ad30c05
Perhaps the testutils package in the past had an `init()` function to set up specific things, but it no longer has. so these imports were doing nothing. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package host
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/docker/docker/libnetwork/types"
|
|
)
|
|
|
|
func TestDriver(t *testing.T) {
|
|
d := &driver{}
|
|
|
|
if d.Type() != networkType {
|
|
t.Fatal("Unexpected network type returned by driver")
|
|
}
|
|
|
|
err := d.CreateNetwork("first", nil, nil, nil, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if d.network != "first" {
|
|
t.Fatal("Unexpected network id stored")
|
|
}
|
|
|
|
err = d.CreateNetwork("second", nil, nil, nil, nil)
|
|
if err == nil {
|
|
t.Fatal("Second network creation should fail on this driver")
|
|
}
|
|
if _, ok := err.(types.ForbiddenError); !ok {
|
|
t.Fatal("Second network creation failed with unexpected error type")
|
|
}
|
|
|
|
err = d.DeleteNetwork("first")
|
|
if err == nil {
|
|
t.Fatal("network deletion should fail on this driver")
|
|
}
|
|
if _, ok := err.(types.ForbiddenError); !ok {
|
|
t.Fatal("network deletion failed with unexpected error type")
|
|
}
|
|
|
|
// we don't really check if it is there or not, delete is not allowed for this driver, period.
|
|
err = d.DeleteNetwork("unknown")
|
|
if err == nil {
|
|
t.Fatal("any network deletion should fail on this driver")
|
|
}
|
|
if _, ok := err.(types.ForbiddenError); !ok {
|
|
t.Fatal("any network deletion failed with unexpected error type")
|
|
}
|
|
}
|