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.
28 lines
454 B
Go
28 lines
454 B
Go
4 years ago
|
package syncx
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestRefCleaner(t *testing.T) {
|
||
|
var count int
|
||
|
clean := func() {
|
||
|
count += 1
|
||
|
}
|
||
|
|
||
|
cleaner := NewRefResource(clean)
|
||
|
err := cleaner.Use()
|
||
|
assert.Nil(t, err)
|
||
|
err = cleaner.Use()
|
||
|
assert.Nil(t, err)
|
||
|
cleaner.Clean()
|
||
|
cleaner.Clean()
|
||
|
assert.Equal(t, 1, count)
|
||
|
cleaner.Clean()
|
||
|
cleaner.Clean()
|
||
|
assert.Equal(t, 1, count)
|
||
|
assert.Equal(t, ErrUseOfCleaned, cleaner.Use())
|
||
|
}
|