Skip to content

Commit

Permalink
another attempt to deal with strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tgummerer committed May 10, 2024
1 parent cf54cda commit 574d0b5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/engine/lifecycletest/test_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path/filepath"
"reflect"
"regexp"
"strings"
"testing"

"github.com/blang/semver"
Expand Down Expand Up @@ -241,13 +242,19 @@ func (op TestOp) runWithContext(
if ok, err := regexp.MatchString(`^[0-9A-Za-z-_]*$`, name); !ok && name != "" {
assert.NoError(opts.T, err)
name = base64.StdEncoding.EncodeToString([]byte(name))

if len(name) > 64 {
name = name[0:64]
}
}
testName := opts.T.Name()
if ok, err := regexp.MatchString(`^[0-9A-Za-z-_]*$`, testName); !ok {
assert.NoError(opts.T, err)
testName = base64.StdEncoding.EncodeToString([]byte(testName))

if ok, _ := regexp.MatchString(`^[0-9A-Za-z-_]*$`, testName); !ok {
testName = strings.ReplaceAll(testName, "[", "_")
testName = strings.ReplaceAll(testName, "]", "_")
testName = strings.ReplaceAll(testName, `"`, "_")
if ok, _ := regexp.MatchString(`^[0-9A-Za-z-_]*$`, testName); !ok {
assert.NoError(opts.T, err)
testName = base64.StdEncoding.EncodeToString([]byte(testName))
}
}
assertDisplay(opts.T, firedEvents, filepath.Join("testdata", "output", testName, name))
}
Expand Down

0 comments on commit 574d0b5

Please sign in to comment.