github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/memdb/revisions_test.go (about) 1 package memdb 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestHeadRevision(t *testing.T) { 12 ds, err := NewMemdbDatastore(0, 0, 500*time.Millisecond) 13 require.NoError(t, err) 14 15 older, err := ds.HeadRevision(context.Background()) 16 require.NoError(t, err) 17 err = ds.CheckRevision(context.Background(), older) 18 require.NoError(t, err) 19 20 time.Sleep(550 * time.Millisecond) 21 22 // GC window elapsed, last revision is returned even if outside GC window 23 newer, err := ds.HeadRevision(context.Background()) 24 require.NoError(t, err) 25 err = ds.CheckRevision(context.Background(), newer) 26 require.NoError(t, err) 27 } 28 29 func (mdb *memdbDatastore) ExampleRetryableError() error { 30 return ErrSerialization 31 }