本文整理汇总了Golang中github.com/keybase/client/go/protocol.NotifyCtlClient.ToggleNotifications方法的典型用法代码示例。如果您正苦于以下问题:Golang NotifyCtlClient.ToggleNotifications方法的具体用法?Golang NotifyCtlClient.ToggleNotifications怎么用?Golang NotifyCtlClient.ToggleNotifications使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/protocol.NotifyCtlClient
的用法示例。
在下文中一共展示了NotifyCtlClient.ToggleNotifications方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSignupLogout
func TestSignupLogout(t *testing.T) {
tc := setupTest(t, "signup")
tc2 := cloneContext(tc)
tc5 := cloneContext(tc)
libkb.G.LocalDb = nil
// Hack the various portions of the service that aren't
// properly contextified.
defer tc.Cleanup()
stopCh := make(chan error)
svc := service.NewService(false, tc.G)
startCh := svc.GetStartChannel()
go func() {
stopCh <- svc.Run()
}()
userInfo := randomUser("sgnup")
sui := signupUI{
info: userInfo,
Contextified: libkb.NewContextified(tc2.G),
}
tc2.G.SetUI(&sui)
signup := client.NewCmdSignupRunner(tc2.G)
signup.SetTest()
logout := client.NewCmdLogoutRunner(tc2.G)
stopper := client.NewCmdCtlStopRunner(tc2.G)
<-startCh
if err := signup.Run(); err != nil {
t.Fatal(err)
}
tc2.G.Log.Debug("Login State: %v", tc2.G.LoginState())
nh := newNotifyHandler()
// Launch the server that will listen for notifications on updates, such as logout
launchServer := func(nh *notifyHandler) error {
cli, xp, err := client.GetRPCClientWithContext(tc5.G)
if err != nil {
return err
}
srv := rpc.NewServer(xp, nil)
if err = srv.Register(keybase1.NotifySessionProtocol(nh)); err != nil {
return err
}
if err = srv.Register(keybase1.NotifyUsersProtocol(nh)); err != nil {
return err
}
ncli := keybase1.NotifyCtlClient{Cli: cli}
if err = ncli.ToggleNotifications(context.TODO(), keybase1.NotificationChannels{
Session: true,
Users: true,
}); err != nil {
return err
}
return nil
}
// Actually launch it in the background
go func() {
err := launchServer(nh)
if err != nil {
nh.errCh <- err
}
}()
btc := client.NewCmdBTCRunner(tc2.G)
btc.SetAddress("1HUCBSJeHnkhzrVKVjaVmWg2QtZS1mdfaz")
if err := btc.Run(); err != nil {
t.Fatal(err)
}
// Now let's be sure that we get a notification back as we expect.
select {
case err := <-nh.errCh:
t.Fatalf("Error before notify: %v", err)
case uid := <-nh.userCh:
tc.G.Log.Debug("Got notification from user changed handled (%s)", uid)
if e := libkb.CheckUIDAgainstUsername(uid, userInfo.username); e != nil {
t.Fatalf("Bad UID back: %s != %s (%s)", uid, userInfo.username, e)
}
}
// Fire a logout
if err := logout.Run(); err != nil {
t.Fatal(err)
}
// Now let's be sure that we get a notification back as we expect.
select {
case err := <-nh.errCh:
t.Fatalf("Error before notify: %v", err)
case <-nh.logoutCh:
//.........这里部分代码省略.........