MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestAccumulate

Function TestAccumulate

internal/util/secrets_test.go:19–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestAccumulate(t *testing.T) {
20 called := 0
21 result, err := accumulate(10, func() (byte, error) {
22 called++
23 //nolint:gosec // G115: called is bounded by test iteration count, no overflow possible.
24 return byte('A' + called), nil
25 })
26
27 assert.NilError(t, err)
28 assert.Equal(t, called, 10)
29 assert.Equal(t, result, "BCDEFGHIJK")
30
31 t.Run("Error", func(t *testing.T) {
32 called := 0
33 expected := errors.New("zap")
34 result, err := accumulate(10, func() (byte, error) {
35 called++
36 if called < 5 {
37 //nolint:gosec // G115: called is bounded by test iteration count, no overflow possible.
38 return byte('A' + called), nil
39 } else {
40 return 'Z', expected
41 }
42 })
43
44 assert.Equal(t, err, expected)
45 assert.Equal(t, called, 5, "expected an early return")
46 assert.Equal(t, result, "")
47 })
48}
49
50func TestGenerateAlphaNumericPassword(t *testing.T) {
51 for _, length := range []int{0, 1, 2, 3, 5, 20, 200} {

Callers

nothing calls this directly

Calls 2

accumulateFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected