2020-11-26 08:01:31 +00:00
|
|
|
package querynode
|
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-07 07:22:20 +00:00
|
|
|
(*tSafe).registerTSafeWatcher(watcher)
|
2020-11-18 08:38:28 +00:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
watcher.hasUpdate()
|
2020-12-07 07:22:20 +00:00
|
|
|
timestamp := (*tSafe).get()
|
2020-11-18 08:38:28 +00:00
|
|
|
assert.Equal(t, timestamp, Timestamp(1000))
|
|
|
|
}()
|
|
|
|
|
2020-12-07 07:22:20 +00:00
|
|
|
(*tSafe).set(Timestamp(1000))
|
2020-11-18 08:38:28 +00:00
|
|
|
}
|