mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
fix: fixed length line numbering when displaying schema validation errors (#741)
Otherwise the indentation does not show correctly. Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/741 Reviewed-by: Gusted <gusted@noreply.code.forgejo.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
e81664ec7b
commit
7ae2bb3c10
2 changed files with 2 additions and 2 deletions
|
@ -190,7 +190,7 @@ func logAndReport(reporter *report.Reporter, message string, args ...any) {
|
||||||
|
|
||||||
func explainFailedGenerateWorkflow(task *runnerv1.Task, log func(message string, args ...any), err error) error {
|
func explainFailedGenerateWorkflow(task *runnerv1.Task, log func(message string, args ...any), err error) error {
|
||||||
for n, line := range strings.Split(string(task.WorkflowPayload), "\n") {
|
for n, line := range strings.Split(string(task.WorkflowPayload), "\n") {
|
||||||
log("%d: %s", n+1, line)
|
log("%5d: %s", n+1, line)
|
||||||
}
|
}
|
||||||
log("Errors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.")
|
log("Errors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.")
|
||||||
for _, line := range strings.Split(err.Error(), "\n") {
|
for _, line := range strings.Split(err.Error(), "\n") {
|
||||||
|
|
|
@ -23,7 +23,7 @@ func TestExplainFailedGenerateWorkflow(t *testing.T) {
|
||||||
generateWorkflowError := errors.New("message 1\nmessage 2")
|
generateWorkflowError := errors.New("message 1\nmessage 2")
|
||||||
err := explainFailedGenerateWorkflow(task, log, generateWorkflowError)
|
err := explainFailedGenerateWorkflow(task, log, generateWorkflowError)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Equal(t, "1: on: [push]\n2: jobs:\n3: \nErrors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.\nmessage 1\nmessage 2\n", logged)
|
assert.Equal(t, " 1: on: [push]\n 2: jobs:\n 3: \nErrors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.\nmessage 1\nmessage 2\n", logged)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLabelUpdate(t *testing.T) {
|
func TestLabelUpdate(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue