1 Star 0 Fork 0

zhuchance / kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
notifications.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"fmt"
"os"
"os/exec"
"github.com/onsi/ginkgo/ginkgo/testsuite"
)
type Notifier struct {
commandFlags *RunWatchAndBuildCommandFlags
}
func NewNotifier(commandFlags *RunWatchAndBuildCommandFlags) *Notifier {
return &Notifier{
commandFlags: commandFlags,
}
}
func (n *Notifier) VerifyNotificationsAreAvailable() {
if n.commandFlags.Notify {
_, err := exec.LookPath("terminal-notifier")
if err != nil {
fmt.Printf(`--notify requires terminal-notifier, which you don't seem to have installed.
To remedy this:
brew install terminal-notifier
To learn more about terminal-notifier:
https://github.com/alloy/terminal-notifier
`)
os.Exit(1)
}
}
}
func (n *Notifier) SendSuiteCompletionNotification(suite testsuite.TestSuite, suitePassed bool) {
if suitePassed {
n.SendNotification("Ginkgo [PASS]", fmt.Sprintf(`Test suite for "%s" passed.`, suite.PackageName))
} else {
n.SendNotification("Ginkgo [FAIL]", fmt.Sprintf(`Test suite for "%s" failed.`, suite.PackageName))
}
}
func (n *Notifier) SendNotification(title string, subtitle string) {
args := []string{"-title", title, "-subtitle", subtitle, "-group", "com.onsi.ginkgo"}
terminal := os.Getenv("TERM_PROGRAM")
if terminal == "iTerm.app" {
args = append(args, "-activate", "com.googlecode.iterm2")
} else if terminal == "Apple_Terminal" {
args = append(args, "-activate", "com.apple.Terminal")
}
if n.commandFlags.Notify {
exec.Command("terminal-notifier", args...).Run()
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/meoom/kubernetes.git
git@gitee.com:meoom/kubernetes.git
meoom
kubernetes
kubernetes
v0.12.2

搜索帮助

344bd9b3 5694891 D2dac590 5694891