Skip to content

Commit 45e5630

Browse files
authored
feat: add a 'description' property into testsuite (#770)
* suite: add a 'description' property This attribute expects a markdown content. If defined, the html output will render it in the 'info' header of the test stuite. * suite description: add a use example in README Signed-off-by: Christophe de Vienne <[email protected]>
1 parent 8e89eca commit 45e5630

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ In `venom` a testsuite is written in one `YAML` file respecting the following st
299299
```yaml
300300
301301
name: Title of TestSuite
302+
description: A detailed description of the TestSuite, in markdown.
302303
testcases:
303304
- name: TestCase with default value, exec cmd. Check if exit code != 1
304305
steps:

process_files.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ func (v *Venom) readFiles(ctx context.Context, filesPath []string) (err error) {
119119
}
120120

121121
ts := TestSuite{
122-
Name: testSuiteInput.Name,
123-
TestCases: make([]TestCase, len(testSuiteInput.TestCases)),
124-
Vars: testSuiteInput.Vars,
125-
Secrets: testSuiteInput.Secrets,
122+
Name: testSuiteInput.Name,
123+
Description: testSuiteInput.Description,
124+
TestCases: make([]TestCase, len(testSuiteInput.TestCases)),
125+
Vars: testSuiteInput.Vars,
126+
Secrets: testSuiteInput.Secrets,
126127
}
127128
for i := range testSuiteInput.TestCases {
128129
ts.TestCases[i] = TestCase{

types.go

+17-13
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,19 @@ type TestSuiteXML struct {
104104
}
105105

106106
type TestSuiteInput struct {
107-
Name string `json:"name" yaml:"name"`
108-
TestCases []TestCaseInput `json:"testcases" yaml:"testcases"`
109-
Vars H `json:"vars" yaml:"vars"`
110-
Secrets []string `json:"secrets" yaml:"secrets"`
107+
Name string `json:"name" yaml:"name"`
108+
Description string `json:"description" yaml:"description"`
109+
TestCases []TestCaseInput `json:"testcases" yaml:"testcases"`
110+
Vars H `json:"vars" yaml:"vars"`
111+
Secrets []string `json:"secrets" yaml:"secrets"`
111112
}
112113

113114
type TestSuite struct {
114-
Name string `json:"name" yaml:"name"`
115-
TestCases []TestCase `json:"testcases" yaml:"testcases"`
116-
Vars H `json:"vars" yaml:"vars"`
117-
Secrets []string `json:"secrets" yaml:"secrets"`
115+
Name string `json:"name" yaml:"name"`
116+
Description string `json:"description,omitempty" yaml:"description"`
117+
TestCases []TestCase `json:"testcases" yaml:"testcases"`
118+
Vars H `json:"vars" yaml:"vars"`
119+
Secrets []string `json:"secrets" yaml:"secrets"`
118120

119121
// computed
120122
ShortName string `json:"shortname" yaml:"-"`
@@ -357,8 +359,10 @@ func RemoveNotPrintableChar(in string) string {
357359
return strings.Map(m, in)
358360
}
359361

360-
var Red = color.New(color.FgRed).SprintFunc()
361-
var Yellow = color.New(color.FgYellow).SprintFunc()
362-
var Green = color.New(color.FgGreen).SprintFunc()
363-
var Cyan = color.New(color.FgCyan).SprintFunc()
364-
var Gray = color.New(color.Attribute(90)).SprintFunc()
362+
var (
363+
Red = color.New(color.FgRed).SprintFunc()
364+
Yellow = color.New(color.FgYellow).SprintFunc()
365+
Green = color.New(color.FgGreen).SprintFunc()
366+
Cyan = color.New(color.FgCyan).SprintFunc()
367+
Gray = color.New(color.Attribute(90)).SprintFunc()
368+
)

venom_output.html

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
99
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
1010
<script src="https://cdnjs.cloudflare.com/ajax/libs/yamljs/0.3.0/yaml.min.js"></script>
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
1112
<style>
1213

1314
@media (min-width: 768px) {
@@ -209,6 +210,11 @@ <h5 class="modal-title" id="varsModalLabel">Test Suite Variables</h5>
209210
var data = a.test_suites[this.id];
210211

211212
var info = "";
213+
if (data.description) {
214+
var converter = new showdown.Converter(),
215+
html = converter.makeHtml(data.description);
216+
info += html;
217+
}
212218
info += '<ul>'
213219

214220
info += '<li>Filepath: <code class="nt">'+data.filepath+'</code></li>';

0 commit comments

Comments
 (0)