// SubscribeUnsubscribe tests Subscribe and Unsubscribe adapter methods
SubscribeUnsubscribe tests Subscribe and Unsubscribe adapter methods
// SubscribeUnsubscribe tests Subscribe and Unsubscribe adapter methods
func SubscribeUnsubscribe(adapterInfo *TestAdapterInfo) (err error) {
	if adapterInfo.SetData == nil {
		return nil
	}
	err = adapterInfo.Adapter.SetData(adapterInfo.SetData)
	if err != nil {
		return err
	}
	if err = adapterInfo.Adapter.Subscribe(adapterInfo.SubscribeList); err != nil {
		return err
	}
	if err = adapterInfo.Adapter.SetData(adapterInfo.SetSubscribeData); err != nil {
		return err
	}
	select {
	case getData := <-adapterInfo.Adapter.GetSubscribeChannel():
		for path, data := range getData {
			if !reflect.DeepEqual(adapterInfo.SetSubscribeData[path], data) {
				return fmt.Errorf("wrong path: %s value: %v", path, data)
			}
		}
	case <-time.After(100 * time.Millisecond):
		return fmt.Errorf("waiting for adapter %s data timeout", adapterInfo.Name)
	}
	if err = adapterInfo.Adapter.Unsubscribe(adapterInfo.SubscribeList); err != nil {
		return err
	}
	return nil
}
func SubscribeUnsubscribe ( adapterInfo * TestAdapterInfo ) ( err error ) { if adapterInfo . SetData == nil { return nil } err = adapterInfo . Adapter . SetData ( adapterInfo . SetData ) if err != nil { return err } if err = adapterInfo . Adapter . Subscribe ( adapterInfo . SubscribeList ) ; err != nil { return err } if err = adapterInfo . Adapter . SetData ( adapterInfo . SetSubscribeData ) ; err != nil { return err } select { case getData := <- adapterInfo . Adapter . GetSubscribeChannel ( ) : for path , data := range getData { if ! reflect . DeepEqual ( adapterInfo . SetSubscribeData [ path ] , data ) { return fmt . Errorf ( " " , path , data ) } } case <- time . After ( 100 * time . Millisecond ) : return fmt . Errorf ( " " , adapterInfo . Name ) } if err = adapterInfo . Adapter . Unsubscribe ( adapterInfo . SubscribeList ) ; err != nil { return err } return nil }
SubscribeUnsubscribe tests Subscribe and Unsubscribe adapter methods
SubscribeUnsubscribe tests Subscribe and Unsubscribe adapter methods
// subscribe // check data // unsubscribe