Skip to content

Commit

Permalink
Update faas-cli version
Browse files Browse the repository at this point in the history
**What**
- Update faas-cli dependency to 0.13.0, this is needed so
  that the logs request is parsed correctly

Signed-off-by: Lucas Roesler <[email protected]>
  • Loading branch information
LucasRoesler authored and alexellis committed Jun 9, 2021
1 parent 05f3dca commit 4860398
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ func Test_FunctionLogs(t *testing.T) {
copy(cnCases, cases)
for index := 0; index < len(cnCases); index++ {
ns := config.Namespaces[0]

newLogs := make([]string, len(cnCases[index].expectedLogs))
copy(newLogs, cnCases[index].expectedLogs)

newLogs[1] = fmt.Sprintf("Wrote %d Bytes", len(ns))
cnCases[index].expectedLogs = newLogs
cnCases[index].function.Namespace = ns
cnCases[index].expectedLogs[1] = fmt.Sprintf("Wrote %d Bytes", len(ns))
}

cases = append(cases, cnCases...)
Expand Down
35 changes: 35 additions & 0 deletions tests/strings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tests

import (
"math/rand"
"strings"
"time"
)

const letterBytes = "abcdefghijklmnopqrstuvwxyz"
const (
letterIdxBits = 6 // 6 bits to represent a letter index
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
)

var src = rand.NewSource(time.Now().UnixNano())

func RandString(n int) string {
sb := strings.Builder{}
sb.Grow(n)
// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
if remain == 0 {
cache, remain = src.Int63(), letterIdxMax
}
if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
sb.WriteByte(letterBytes[idx])
i--
}
cache >>= letterIdxBits
remain--
}

return sb.String()
}

0 comments on commit 4860398

Please sign in to comment.