#1: User golang 1.12 for travis build. Improve random usernames generator

This commit is contained in:
ErickSkrauch 2019-04-20 20:04:57 +03:00
parent 96af45b2a1
commit bd099cfb2a
2 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@ sudo: required
language: go
go:
- 1.9
- 1.12
services:
- docker

View File

@ -261,11 +261,13 @@ func TestJobsQueueSuite(t *testing.T) {
suite.Run(t, new(QueueTestSuite))
}
var replacer = strings.NewReplacer("-", "_", "=", "")
// https://stackoverflow.com/a/50581165
func randStr(len int) string {
buff := make([]byte, len)
_, _ = rand.Read(buff)
str := strings.ReplaceAll(base64.URLEncoding.EncodeToString(buff), "-", "_")
str := replacer.Replace(base64.URLEncoding.EncodeToString(buff))
// Base 64 can be longer than len
return str[:len]