github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/idutil/tlf_names_test.go (about) 1 // Copyright 2019 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package idutil 6 7 import ( 8 "testing" 9 10 "github.com/keybase/client/go/kbfs/tlf" 11 "github.com/stretchr/testify/assert" 12 "github.com/stretchr/testify/require" 13 ) 14 15 func TestNormalizeNamesInTLF(t *testing.T) { 16 writerNames := []string{"BB", "C@Twitter", "d@twitter", "aa"} 17 readerNames := []string{"EE", "ff", "AA@HackerNews", "aa", "BB", "bb", "ZZ@hackernews"} 18 s, changes, err := NormalizeNamesInTLF( 19 writerNames, readerNames, tlf.Private, "") 20 require.NoError(t, err) 21 require.True(t, changes) 22 assert.Equal(t, "aa,bb,c@twitter,d@twitter#AA@hackernews,ZZ@hackernews,aa,bb,bb,ee,ff", s) 23 } 24 25 func TestNormalizeNamesInTLFWithConflict(t *testing.T) { 26 writerNames := []string{"BB", "C@Twitter", "d@twitter", "aa"} 27 readerNames := []string{"EE", "ff", "AA@HackerNews", "aa", "BB", "bb", "ZZ@hackernews"} 28 conflictSuffix := "(cOnflictED coPy 2015-05-11 #4)" 29 s, changes, err := NormalizeNamesInTLF( 30 writerNames, readerNames, tlf.Private, conflictSuffix) 31 require.NoError(t, err) 32 require.True(t, changes) 33 assert.Equal(t, "aa,bb,c@twitter,d@twitter#AA@hackernews,ZZ@hackernews,aa,bb,bb,ee,ff (conflicted copy 2015-05-11 #4)", s) 34 }