github.com/storacha/go-ucanto@v0.7.2/principal/multiformat/multiformat_test.go (about)

     1  package multiformat
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/storacha/go-ucanto/testing/helpers"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestTag(t *testing.T) {
    11  	t.Run("round trip", func(t *testing.T) {
    12  		b := []byte{1, 2, 3}
    13  		tb := TagWith(1, b)
    14  		utb := helpers.Must(UntagWith(1, tb, 0))
    15  		require.EqualValues(t, b, utb)
    16  	})
    17  
    18  	t.Run("incorrect tag", func(t *testing.T) {
    19  		b := []byte{1, 2, 3}
    20  		tb := TagWith(1, b)
    21  		_, err := UntagWith(2, tb, 0)
    22  		require.Error(t, err)
    23  		require.Equal(t, "expected multiformat with 0x2 tag instead got 0x1", err.Error())
    24  	})
    25  }