mirror of
https://github.com/restic/restic.git
synced 2026-05-19 00:25:23 +00:00
Update github.com/jessevdk/go-flags
This commit is contained in:
@@ -185,3 +185,71 @@ func TestDuplicateLongFlags(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindOptionByLongFlag(t *testing.T) {
|
||||
var opts struct {
|
||||
Testing bool `long:"testing" description:"Testing"`
|
||||
}
|
||||
|
||||
p := NewParser(&opts, Default)
|
||||
opt := p.FindOptionByLongName("testing")
|
||||
|
||||
if opt == nil {
|
||||
t.Errorf("Expected option, but found none")
|
||||
}
|
||||
|
||||
assertString(t, opt.LongName, "testing")
|
||||
}
|
||||
|
||||
func TestFindOptionByShortFlag(t *testing.T) {
|
||||
var opts struct {
|
||||
Testing bool `short:"t" description:"Testing"`
|
||||
}
|
||||
|
||||
p := NewParser(&opts, Default)
|
||||
opt := p.FindOptionByShortName('t')
|
||||
|
||||
if opt == nil {
|
||||
t.Errorf("Expected option, but found none")
|
||||
}
|
||||
|
||||
if opt.ShortName != 't' {
|
||||
t.Errorf("Expected 't', but got %v", opt.ShortName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindOptionByLongFlagInSubGroup(t *testing.T) {
|
||||
var opts struct {
|
||||
Group struct {
|
||||
Testing bool `long:"testing" description:"Testing"`
|
||||
} `group:"sub-group"`
|
||||
}
|
||||
|
||||
p := NewParser(&opts, Default)
|
||||
opt := p.FindOptionByLongName("testing")
|
||||
|
||||
if opt == nil {
|
||||
t.Errorf("Expected option, but found none")
|
||||
}
|
||||
|
||||
assertString(t, opt.LongName, "testing")
|
||||
}
|
||||
|
||||
func TestFindOptionByShortFlagInSubGroup(t *testing.T) {
|
||||
var opts struct {
|
||||
Group struct {
|
||||
Testing bool `short:"t" description:"Testing"`
|
||||
} `group:"sub-group"`
|
||||
}
|
||||
|
||||
p := NewParser(&opts, Default)
|
||||
opt := p.FindOptionByShortName('t')
|
||||
|
||||
if opt == nil {
|
||||
t.Errorf("Expected option, but found none")
|
||||
}
|
||||
|
||||
if opt.ShortName != 't' {
|
||||
t.Errorf("Expected 't', but got %v", opt.ShortName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user