github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/graph/limits_test.go (about) 1 package graph 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestLimitsPrepareForPublishing(t *testing.T) { 10 limits := newLimitTracker(10) 11 12 for i := 0; i < 10; i++ { 13 result := limits.prepareForPublishing() 14 require.True(t, result) 15 } 16 17 result := limits.prepareForPublishing() 18 require.False(t, result) 19 } 20 21 func TestLimitsMarkAlreadyPublished(t *testing.T) { 22 limits := newLimitTracker(10) 23 24 err := limits.markAlreadyPublished(5) 25 require.Nil(t, err) 26 27 err = limits.markAlreadyPublished(5) 28 require.Nil(t, err) 29 30 require.Panics(t, func() { 31 _ = limits.markAlreadyPublished(1) 32 }) 33 }