2015-06-08 11:24:43 -04:00
|
|
|
package null
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-04-05 20:24:47 -04:00
|
|
|
"github.com/docker/docker/libnetwork/types"
|
2015-06-08 11:24:43 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDriver(t *testing.T) {
|
|
|
|
d := &driver{}
|
|
|
|
|
|
|
|
if d.Type() != networkType {
|
|
|
|
t.Fatalf("Unexpected network type returned by driver")
|
|
|
|
}
|
|
|
|
|
2016-04-18 22:55:39 -04:00
|
|
|
err := d.CreateNetwork("first", nil, nil, nil, nil)
|
2015-06-08 11:24:43 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if d.network != "first" {
|
|
|
|
t.Fatalf("Unexpected network id stored")
|
|
|
|
}
|
|
|
|
|
2016-04-18 22:55:39 -04:00
|
|
|
err = d.CreateNetwork("second", nil, nil, nil, nil)
|
2015-06-08 11:24:43 -04:00
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("Second network creation should fail on this driver")
|
|
|
|
}
|
|
|
|
if _, ok := err.(types.ForbiddenError); !ok {
|
|
|
|
t.Fatalf("Second network creation failed with unexpected error type")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = d.DeleteNetwork("first")
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("network deletion should fail on this driver")
|
|
|
|
}
|
|
|
|
if _, ok := err.(types.ForbiddenError); !ok {
|
|
|
|
t.Fatalf("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.Fatalf("any network deletion should fail on this driver")
|
|
|
|
}
|
|
|
|
if _, ok := err.(types.ForbiddenError); !ok {
|
|
|
|
t.Fatalf("any network deletion failed with unexpected error type")
|
|
|
|
}
|
|
|
|
}
|