nanomsg.org/go/mangos/v2@v2.0.9-0.20200203084354-8a092611e461/protocol/push/push_test.go (about)

     1  // Copyright 2019 The Mangos Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use file except in compliance with the License.
     5  // You may obtain a copy of the license at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package push
    16  
    17  import (
    18  	"nanomsg.org/go/mangos/v2"
    19  	"testing"
    20  
    21  	. "nanomsg.org/go/mangos/v2/internal/test"
    22  )
    23  
    24  func TestPushIdentity(t *testing.T) {
    25  	s := GetSocket(t, NewSocket)
    26  	id := s.Info()
    27  	MustBeTrue(t, id.Self == mangos.ProtoPush)
    28  	MustBeTrue(t, id.SelfName == "push")
    29  	MustBeTrue(t, id.Peer == mangos.ProtoPull)
    30  	MustBeTrue(t, id.PeerName == "pull")
    31  	MustSucceed(t, s.Close())
    32  }
    33  
    34  func TestPushCooked(t *testing.T) {
    35  	VerifyCooked(t, NewSocket)
    36  }
    37  
    38  func TestPushNoContext(t *testing.T) {
    39  	s := GetSocket(t, NewSocket)
    40  	_, e := s.OpenContext()
    41  	MustBeError(t, e, mangos.ErrProtoOp)
    42  	MustSucceed(t, s.Close())
    43  }
    44  
    45  func TestPushOptions(t *testing.T) {
    46  	VerifyInvalidOption(t, NewSocket)
    47  }
    48  
    49  func TestPushNoRecv(t *testing.T) {
    50  	CannotRecv(t, NewSocket)
    51  }