2016-12-12 18:05:53 -05:00
|
|
|
package plugin
|
2016-10-25 19:12:56 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/plugin/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFilterByCapNeg(t *testing.T) {
|
2016-12-12 18:05:53 -05:00
|
|
|
p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
|
2017-03-20 04:27:51 -04:00
|
|
|
iType := types.PluginInterfaceType{Capability: "volumedriver", Prefix: "docker", Version: "1.0"}
|
|
|
|
i := types.PluginConfigInterface{Socket: "plugins.sock", Types: []types.PluginInterfaceType{iType}}
|
2016-11-07 21:51:47 -05:00
|
|
|
p.PluginObj.Config.Interface = i
|
2016-10-25 19:12:56 -04:00
|
|
|
|
|
|
|
_, err := p.FilterByCap("foobar")
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("expected inadequate error, got %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFilterByCapPos(t *testing.T) {
|
2016-12-12 18:05:53 -05:00
|
|
|
p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
|
2016-10-25 19:12:56 -04:00
|
|
|
|
2017-03-20 04:27:51 -04:00
|
|
|
iType := types.PluginInterfaceType{Capability: "volumedriver", Prefix: "docker", Version: "1.0"}
|
|
|
|
i := types.PluginConfigInterface{Socket: "plugins.sock", Types: []types.PluginInterfaceType{iType}}
|
2016-11-07 21:51:47 -05:00
|
|
|
p.PluginObj.Config.Interface = i
|
2016-10-25 19:12:56 -04:00
|
|
|
|
|
|
|
_, err := p.FilterByCap("volumedriver")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("expected no error, got %v", err)
|
|
|
|
}
|
|
|
|
}
|