github.com/SamWhited/moby@v1.13.1/plugin/store_test.go (about)

     1  package plugin
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/docker/docker/api/types"
     7  	"github.com/docker/docker/plugin/v2"
     8  )
     9  
    10  func TestFilterByCapNeg(t *testing.T) {
    11  	p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
    12  	iType := types.PluginInterfaceType{"volumedriver", "docker", "1.0"}
    13  	i := types.PluginConfigInterface{"plugins.sock", []types.PluginInterfaceType{iType}}
    14  	p.PluginObj.Config.Interface = i
    15  
    16  	_, err := p.FilterByCap("foobar")
    17  	if err == nil {
    18  		t.Fatalf("expected inadequate error, got %v", err)
    19  	}
    20  }
    21  
    22  func TestFilterByCapPos(t *testing.T) {
    23  	p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
    24  
    25  	iType := types.PluginInterfaceType{"volumedriver", "docker", "1.0"}
    26  	i := types.PluginConfigInterface{"plugins.sock", []types.PluginInterfaceType{iType}}
    27  	p.PluginObj.Config.Interface = i
    28  
    29  	_, err := p.FilterByCap("volumedriver")
    30  	if err != nil {
    31  		t.Fatalf("expected no error, got %v", err)
    32  	}
    33  }