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