get.porter.sh/porter@v1.3.0/pkg/pkgmgmt/uninstall_test.go (about) 1 package pkgmgmt 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestUninstallOptions_Validate(t *testing.T) { 11 t.Run("no name", func(t *testing.T) { 12 opts := UninstallOptions{} 13 err := opts.Validate(nil) 14 require.EqualError(t, err, "no name was specified") 15 }) 16 t.Run("name specified", func(t *testing.T) { 17 opts := UninstallOptions{} 18 err := opts.Validate([]string{"thename"}) 19 require.NoError(t, err) 20 assert.Equal(t, "thename", opts.Name, "the package name was not captured") 21 }) 22 t.Run("multiple names specified", func(t *testing.T) { 23 opts := UninstallOptions{} 24 err := opts.Validate([]string{"name1", "name2"}) 25 require.EqualError(t, err, "only one positional argument may be specified, the name, but multiple were received: [name1 name2]") 26 }) 27 }