You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bog/dataswamp/namespace/valueobjects_test.go

38 lines
652 B
Go

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))
}