Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion experimental/plugins/macro/macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func expandToken(tx plugintypes.TransactionState, token macroToken) string {
}

// If the variable is known (e.g. TX) but the key is not found, we return the original text
tx.DebugLogger().Warn().Str("variable", token.variable.Name()).Str("key", token.key).Msg("key not found in collection, returning the original text")
tx.DebugLogger().Debug().Str("variable", token.variable.Name()).Str("key", token.key).Msg("key not found in collection, returning the original text")
return token.text
}

Expand Down
10 changes: 9 additions & 1 deletion internal/actions/setvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,56 +67,64 @@ func TestSetvarEvaluate(t *testing.T) {
init2 string
expectInvalidSyntaxError bool
expectNewVarValue string
logLevel debuglog.Level
}{
{
name: "Numerical operation + with existing variable",
init: "TX.var=5",
init2: "TX.newvar=+%{tx.var}",
expectInvalidSyntaxError: false,
expectNewVarValue: "5",
logLevel: debuglog.LevelError,
},
{
name: "Numerical operation - with existing variable",
init: "TX.var=5",
init2: "TX.newvar=-%{tx.var}",
expectInvalidSyntaxError: false,
expectNewVarValue: "-5",
logLevel: debuglog.LevelError,
},
{
name: "Numerical operation - with existing negative variable",
init: "TX.newvar=-5",
init2: "TX.newvar=+5",
expectInvalidSyntaxError: false,
expectNewVarValue: "0",
logLevel: debuglog.LevelError,
},
{
name: "Numerical operation + with missing (or non-numerical) variable",
init: "TX.newvar=+%{tx.missingvar}",
expectInvalidSyntaxError: true,
logLevel: debuglog.LevelDebug,
},
{
name: "Numerical operation - with missing (or non-numerical) variable",
init: "TX.newvar=-%{tx.missingvar}",
expectInvalidSyntaxError: true,
logLevel: debuglog.LevelDebug,
},
{
name: "Non Numerical Operation - If the value starts with -",
init: "TX.newvar=----expected_value",
expectInvalidSyntaxError: false,
expectNewVarValue: "----expected_value",
logLevel: debuglog.LevelError,
},
{
name: "Non Numerical Operation - If the value starts with +",
init: "TX.newvar=+++expected_value",
expectInvalidSyntaxError: false,
expectNewVarValue: "+++expected_value",
logLevel: debuglog.LevelError,
},
}

for _, tt := range tests {
logsBuf := &bytes.Buffer{}

logger := debuglog.Default().WithLevel(debuglog.LevelWarn).WithOutput(logsBuf)
logger := debuglog.Default().WithLevel(tt.logLevel).WithOutput(logsBuf)

t.Run(tt.name, func(t *testing.T) {
defer logsBuf.Reset()
Expand Down
Loading