mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-22 02:41:23 +01:00
* token swap * setting environment variables for different local/remote shells * bug fixes for init scripts * more logging * update connserver startup flow
47 lines
904 B
Go
47 lines
904 B
Go
package ds
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSyncMap_Set(t *testing.T) {
|
|
sm := MakeSyncMap[int]()
|
|
sm.Set("key1", 1)
|
|
if sm.Get("key1") != 1 {
|
|
t.Errorf("expected 1, got %d", sm.Get("key1"))
|
|
}
|
|
}
|
|
|
|
func TestSyncMap_Get(t *testing.T) {
|
|
sm := MakeSyncMap[int]()
|
|
sm.Set("key1", 1)
|
|
if sm.Get("key1") != 1 {
|
|
t.Errorf("expected 1, got %d", sm.Get("key1"))
|
|
}
|
|
if sm.Get("key2") != 0 {
|
|
t.Errorf("expected 0, got %d", sm.Get("key2"))
|
|
}
|
|
}
|
|
|
|
func TestSyncMap_GetEx(t *testing.T) {
|
|
sm := MakeSyncMap[int]()
|
|
sm.Set("key1", 1)
|
|
value, ok := sm.GetEx("key1")
|
|
if !ok || value != 1 {
|
|
t.Errorf("expected 1, got %d", value)
|
|
}
|
|
value, ok = sm.GetEx("key2")
|
|
if ok || value != 0 {
|
|
t.Errorf("expected 0, got %d", value)
|
|
}
|
|
}
|
|
|
|
func TestSyncMap_Delete(t *testing.T) {
|
|
sm := MakeSyncMap[int]()
|
|
sm.Set("key1", 1)
|
|
sm.Delete("key1")
|
|
if sm.Get("key1") != 0 {
|
|
t.Errorf("expected 0, got %d", sm.Get("key1"))
|
|
}
|
|
}
|