github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/updater/util/rand_test.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package util 5 6 import ( 7 "strings" 8 "testing" 9 ) 10 11 func TestRandString(t *testing.T) { 12 s, err := RandomID("prefix=") 13 t.Logf("Rand string: %s", s) 14 if err != nil { 15 t.Fatal(err) 16 } 17 if !strings.HasPrefix(s, "prefix=") { 18 t.Errorf("Invalid prefix: %s", s) 19 } 20 if len(s)-len("prefix.") != 52 { 21 t.Errorf("Invalid length: %s (%d)", s, len(s)) 22 } 23 }