Enchantrix/pkg/crypt/std/lthn/lthn_keymap_test.go
google-labs-jules[bot] edb8b8f98e fix(tests): address race conditions and incorrect mocks
- Refactors the `lthn` keymap test to be thread-safe by using a mutex and `t.Cleanup` to ensure state is properly restored.
- Corrects the `mockReader` implementation in the `trix` tests to adhere to the `io.Reader` interface contract.
2025-11-03 00:29:26 +00:00

25 lines
386 B
Go

package lthn
import (
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
var testKeyMapMu sync.Mutex
func TestSetKeyMap(t *testing.T) {
testKeyMapMu.Lock()
originalKeyMap := GetKeyMap()
t.Cleanup(func() {
SetKeyMap(originalKeyMap)
testKeyMapMu.Unlock()
})
newKeyMap := map[rune]rune{
'a': 'b',
}
SetKeyMap(newKeyMap)
assert.Equal(t, newKeyMap, GetKeyMap())
}