github.com/emitter-io/go/v2@v2.1.0/types_test.go (about)

     1  // Copyright (c) Roman Atachiants and contributors. All rights reserved.
     2  // Licensed under the MIT license. See LICENSE file in the project root for details.
     3  
     4  package emitter
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestUUID(t *testing.T) {
    13  	id := uuid()
    14  
    15  	assert.NotNil(t, id)
    16  	assert.Len(t, id, 36)
    17  }
    18  
    19  type message struct {
    20  	duplicate bool
    21  	qos       byte
    22  	retained  bool
    23  	topic     string
    24  	messageID uint16
    25  	payload   string
    26  }
    27  
    28  func (m *message) Duplicate() bool {
    29  	return m.duplicate
    30  }
    31  
    32  func (m *message) Qos() byte {
    33  	return m.qos
    34  }
    35  
    36  func (m *message) Retained() bool {
    37  	return m.retained
    38  }
    39  
    40  func (m *message) Topic() string {
    41  	return m.topic
    42  }
    43  
    44  func (m *message) MessageID() uint16 {
    45  	return m.messageID
    46  }
    47  
    48  func (m *message) Payload() []byte {
    49  	return []byte(m.payload)
    50  }
    51  
    52  func (m *message) Ack() {
    53  }