mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
977109d808
Instead of using a global store for volume drivers, scope the driver store to the caller (e.g. the volume store). This makes testing much simpler. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
24 lines
511 B
Go
24 lines
511 B
Go
package drivers // import "github.com/docker/docker/volume/drivers"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
volumetestutils "github.com/docker/docker/volume/testutils"
|
|
)
|
|
|
|
func TestGetDriver(t *testing.T) {
|
|
s := NewStore(nil)
|
|
_, err := s.GetDriver("missing")
|
|
if err == nil {
|
|
t.Fatal("Expected error, was nil")
|
|
}
|
|
s.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
|
|
|
d, err := s.GetDriver("fake")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if d.Name() != "fake" {
|
|
t.Fatalf("Expected fake driver, got %s\n", d.Name())
|
|
}
|
|
}
|