package namespace import ( "github.com/matryer/is" "testing" ) func TestQuota(t *testing.T) { is := is.New(t) quota := FileSizeQuota{1000, 0} is.True(quota.Allows(1000)) is.True(!quota.Allows(1001)) } func TestQuotaManipulation(t *testing.T) { is := is.New(t) quota := FileSizeQuota{1000, 0} is.NoErr(quota.Add(500)) is.Equal(quota.CurrentUsage, int64(500)) is.NoErr(quota.Add(500)) is.Equal(quota.Add(1), ErrExceedQuota) is.Equal(quota.CurrentUsage, int64(1000)) is.Equal(quota.Remove(1001), ErrQuotaInvalid) is.Equal(quota.CurrentUsage, int64(1000)) is.NoErr(quota.Remove(1000)) is.Equal(quota.CurrentUsage, int64(0)) }