2021-01-15 07:28:54 +00:00
|
|
|
package querynodeimp
|
2020-11-18 08:38:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTSafe_GetAndSet(t *testing.T) {
|
|
|
|
tSafe := newTSafe()
|
|
|
|
watcher := newTSafeWatcher()
|
2020-12-08 06:41:04 +00:00
|
|
|
tSafe.registerTSafeWatcher(watcher)
|
2020-11-18 08:38:28 +00:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
watcher.hasUpdate()
|
2020-12-08 06:41:04 +00:00
|
|
|
timestamp := tSafe.get()
|
2020-11-18 08:38:28 +00:00
|
|
|
assert.Equal(t, timestamp, Timestamp(1000))
|
|
|
|
}()
|
|
|
|
|
2020-12-08 06:41:04 +00:00
|
|
|
tSafe.set(Timestamp(1000))
|
2020-11-18 08:38:28 +00:00
|
|
|
}
|