Fix test.

This commit is contained in:
Nuno Cruces 2022-05-02 15:51:21 +01:00
parent 270b1a0c0e
commit bc5d47ca8d
2 changed files with 4 additions and 4 deletions

View file

@ -5,7 +5,7 @@ import (
) )
func list(text string, items []string, opts options) (string, error) { func list(text string, items []string, opts options) (string, error) {
if opts.extraButton != nil { if len(items) == 0 || opts.extraButton != nil {
return "", ErrUnsupported return "", ErrUnsupported
} }
@ -23,7 +23,7 @@ func list(text string, items []string, opts options) (string, error) {
} }
func listMultiple(text string, items []string, opts options) ([]string, error) { func listMultiple(text string, items []string, opts options) ([]string, error) {
if opts.extraButton != nil { if len(items) == 0 || opts.extraButton != nil {
return nil, ErrUnsupported return nil, ErrUnsupported
} }

View file

@ -48,7 +48,7 @@ func TestList_timeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second/5) ctx, cancel := context.WithTimeout(context.Background(), time.Second/5)
defer cancel() defer cancel()
_, err := zenity.List("", nil, zenity.Context(ctx)) _, err := zenity.List("", []string{""}, zenity.Context(ctx))
if skip, err := skip(err); skip { if skip, err := skip(err); skip {
t.Skip("skipping:", err) t.Skip("skipping:", err)
} }
@ -62,7 +62,7 @@ func TestList_cancel(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
cancel() cancel()
_, err := zenity.List("", nil, zenity.Context(ctx)) _, err := zenity.List("", []string{""}, zenity.Context(ctx))
if skip, err := skip(err); skip { if skip, err := skip(err); skip {
t.Skip("skipping:", err) t.Skip("skipping:", err)
} }