zenity/notify_test.go

29 lines
522 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))
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
}
}