github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/disable_backup_darwin_test.go (about) 1 //go:build darwin 2 // +build darwin 3 4 package libkb 5 6 import ( 7 "crypto/sha256" 8 "testing" 9 10 "github.com/pkg/xattr" 11 "github.com/stretchr/testify/require" 12 ) 13 14 func TestSetDisableBackup(t *testing.T) { 15 tc := SetupTest(t, "erasable kv store disable backup", 1) 16 defer tc.Cleanup() 17 mctx := NewMetaContextForTest(tc) 18 19 subDir := "" 20 s := NewFileErasableKVStore(mctx, subDir, func(_ MetaContext, noise NoiseBytes) ([32]byte, error) { 21 return sha256.Sum256(noise[:]), nil 22 }) 23 key := "test-key" 24 value := "value" 25 26 require.NoError(t, s.Put(mctx, key, value)) 27 28 storageDir := getStorageDir(mctx, subDir) 29 // Check that we set noBackup on the key 30 metadata, err := xattr.Get(storageDir, key) 31 require.NoError(t, err) 32 require.Equal(t, []byte(noBackup), metadata) 33 34 // Check that we set noBackup on the noise 35 metadata, err = xattr.Get(storageDir, key+noiseSuffix) 36 require.NoError(t, err) 37 require.Equal(t, []byte(noBackup), metadata) 38 }