Skip to content

Commit 1023ec0

Browse files
Testx new api list (#168)
* rename {get,list,cancel}x subcommands * bugfix * rename "test" to "smart-test" * execution subcommand * add x alias * add -f to smart-test run * rebase of api refactor onto new command * add testname to list output * truncate test name --------- Co-authored-by: Daniel De Vera <daniel@signadot.com>
1 parent 40ced6e commit 1023ec0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

internal/command/smarttest/print.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func getResults(tx *models.TestExecution) string {
119119
type testExecRow struct {
120120
ID string `sdtab:"ID"`
121121
Source string `sdtab:"SOURCE"`
122+
TestName string `sdtab:"TESTNAME"`
122123
Phase string `sdtab:"PHASE"`
123124
CreatedAt string `sdtab:"CREATED"`
124125
}
@@ -132,12 +133,29 @@ func printTestExecutionsTable(w io.Writer, txs []*models.TestexecutionsQueryResu
132133
if tx.Spec != nil && tx.Spec.External != nil {
133134
source = "external"
134135
}
136+
var testName string
137+
if tx.Spec != nil {
138+
if tx.Spec.External != nil {
139+
testName = tx.Spec.External.TestName
140+
} else if tx.Spec.Hosted != nil {
141+
testName = tx.Spec.Hosted.TestName
142+
}
143+
}
135144
tab.AddRow(testExecRow{
136145
ID: tx.ID,
137146
Source: source,
147+
TestName: truncateTestName(testName),
138148
CreatedAt: tx.CreatedAt,
139149
Phase: tx.Status.Phase,
140150
})
141151
}
142152
return tab.Flush()
143153
}
154+
155+
func truncateTestName(tn string) string {
156+
N := 48
157+
if len(tn) > N {
158+
return "..." + tn[45:]
159+
}
160+
return tn
161+
}

0 commit comments

Comments
 (0)