github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/mysql/revisions_test.go (about)

     1  package mysql
     2  
     3  import (
     4  	"math"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"github.com/authzed/spicedb/internal/datastore/revisions"
    10  	"github.com/authzed/spicedb/pkg/datastore"
    11  )
    12  
    13  func TestRevisionFromTransaction(t *testing.T) {
    14  	tests := []struct {
    15  		name string
    16  		txID uint64
    17  		want datastore.Revision
    18  	}{
    19  		{"0", 0, revisions.NewForTransactionID(0)},
    20  		{"uint64 max", math.MaxUint64, revisions.NewForTransactionID(math.MaxUint64)},
    21  	}
    22  
    23  	for _, tt := range tests {
    24  		tt := tt
    25  		t.Run(tt.name, func(t *testing.T) {
    26  			require := require.New(t)
    27  			got := revisions.NewForTransactionID(tt.txID)
    28  			require.True(tt.want.Equal(got))
    29  		})
    30  	}
    31  }