github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/secrets/secrets_test.go (about)

     1  package secrets
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  var tests = []uint8{
    10  	0, 1, 2, 4, 8, 16, 128, 255,
    11  }
    12  
    13  func TestTokenBytes(t *testing.T) {
    14  	assert := assert.New(t)
    15  	for _, nbytes := range tests {
    16  		res, err := TokenBytes(nbytes)
    17  		assert.Nil(err)
    18  		assert.Equal(int(nbytes), len(res))
    19  	}
    20  }
    21  
    22  func TestTokenHex(t *testing.T) {
    23  	assert := assert.New(t)
    24  	for _, nbytes := range tests {
    25  		res, err := TokenHex(nbytes)
    26  		assert.Nil(err)
    27  		assert.Equal(int(nbytes)*2, len(res))
    28  	}
    29  }