zenity/notify_test.go

32 lines
587 B
Go
Raw Permalink Normal View History

2020-01-26 11:04:49 -05:00
package zenity_test
2020-01-29 06:09:06 -05:00
import (
"context"
"errors"
"testing"
"github.com/ncruces/zenity"
2021-04-30 14:19:14 -04:00
"go.uber.org/goleak"
2020-01-29 06:09:06 -05:00
)
2020-01-26 11:04:49 -05:00
func ExampleNotify() {
2020-01-26 11:31:23 -05:00
zenity.Notify("There are system updates necessary!",
zenity.Title("Warning"),
2021-05-11 09:58:04 -04:00
zenity.InfoIcon)
2020-01-26 11:04:49 -05:00
// Output:
}
2020-01-29 06:09:06 -05:00
2021-04-30 14:19:14 -04:00
func TestNotify_cancel(t *testing.T) {
defer goleak.VerifyNone(t)
2020-01-29 06:09:06 -05:00
ctx, cancel := context.WithCancel(context.Background())
cancel()
err := zenity.Notify("text", zenity.Context(ctx))
2021-07-06 20:01:22 -04:00
if skip, err := skip(err); skip {
2021-06-18 10:04:09 -04:00
t.Skip("skipping:", err)
}
2020-01-29 06:09:06 -05:00
if !errors.Is(err, context.Canceled) {
2020-01-29 09:15:21 -05:00
t.Error("was not canceled:", err)
2020-01-29 06:09:06 -05:00
}
}