github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/tlf/name_test.go (about) 1 // Copyright 2017 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 tlf 6 7 import ( 8 "testing" 9 10 kbname "github.com/keybase/client/go/kbun" 11 "github.com/stretchr/testify/assert" 12 ) 13 14 func TestCanonicalToPreferredName(t *testing.T) { 15 for _, q := range []struct { 16 As kbname.NormalizedUsername 17 Try CanonicalName 18 Answer PreferredName 19 }{ 20 {"", "a,b,c", "a,b,c"}, 21 {"a", "a,b,c", "a,b,c"}, 22 {"b", "a,b,c", "b,a,c"}, 23 {"c", "a,b,c", "c,a,b"}, 24 {"b", "a,b,c#d,e", "b,a,c#d,e"}, 25 {"d", "a,b,c#d,e", "a,b,c#d,e"}, 26 {"e", "a,b,c#d,e", "a,b,c#e,d"}, 27 } { 28 r, err := CanonicalToPreferredName(q.As, q.Try) 29 assert.Equal(t, q.Answer, r) 30 assert.NoError(t, err) 31 } 32 }