go-pattern-examples/behavior/03_observer/obserser_test.go

30 lines
513 B
Go
Raw Normal View History

2020-04-21 17:50:21 +03:00
package observer
2020-05-02 16:23:04 +03:00
import (
"context"
"testing"
)
func TestObserver(t *testing.T) {
//内容提供商科技BBS
techInfoProvider := TechBBS{}
lily := User{"Lily"}
jacky := User{"Jacky"}
techInfoProvider.Registry(&lily)
techInfoProvider.Registry(&jacky)
updateKey := updates{}
updateValue := updates{topic: "cosmos", order: 1001}
updateContent := context.WithValue(context.Background(), updateKey, updateValue)
techInfoProvider.SetConext(updateContent)
techInfoProvider.noticeAllUpdate()
2020-04-21 17:50:21 +03:00
}