@@ -17,6 +17,8 @@ import (
1717 "github.com/pkg/errors"
1818)
1919
20+ // staticColumns will always be present in the CSV file
21+ // but there can be additional columns for steps and custom fields.
2022var staticColumns = []string {
2123 "Folder" , "Type" , "Name" , "Legacy ID" , "Draft" , "Priority" , "Tags" , "Requirements" ,
2224 "Links" , "Files" , "Preconditions" , "Parameter Values" , "Template Suffix Params" ,
@@ -52,7 +54,11 @@ type Link struct {
5254 URL string `validate:"required,http_url,max=255"`
5355}
5456
55- // File represents an external file.
57+ // File represents an attachment or file associated with a test case.
58+ // These files need to be uploaded to the QA Sphere project via the API
59+ // See API documentation for more details.
60+ //
61+ // https://docs.qasphere.com/api/upload_file
5662type File struct {
5763 Name string `validate:"required" json:"fileName"`
5864 ID string `validate:"required" json:"id"`
@@ -69,7 +75,10 @@ type Step struct {
6975 Expected string
7076}
7177
72- // ParameterValue represents a parameter value to be used for the test case
78+ // ParameterValue represents parameter values that you provide for template test cases.
79+ // Template test cases are test cases where the body of the test case can contain some placeholders
80+ // of the form ${parameter_name}. Then the users need to provide the values for these parameters
81+ // in the form of a map. These are used to generate a filled test case which replaced the placeholders.
7382type ParameterValue struct {
7483 Priority * Priority `json:"priority,omitempty" validate:"oneof=low medium high"`
7584 Values map [string ]string `json:"values" validate:"required,dive,keys,max=255,endkeys"`
@@ -97,6 +106,7 @@ type TestCase struct {
97106 // The title of the test case. (required)
98107 Title string `validate:"required,max=511"`
99108 // The type of the test case. (optional)
109+ // If not specified, it defaults to "standalone".
100110 Type TestCaseType `validate:"omitempty,oneof=standalone template"`
101111 // In case of migrating from another test management system, the
102112 // test case ID in the existing test management system. This is only
@@ -128,8 +138,15 @@ type TestCase struct {
128138 // published. (optional)
129139 Draft bool
130140 // The parameter values to be used for the test case. (optional)
141+ // This is used for template test cases where the body of the test case
142+ // can contain some placeholders of the form ${parameter_name}.
143+ // For each ParameterValue provided in this array, we generate a distinct filled test case
144+ // See ParameterValue for more details.
131145 ParameterValues []ParameterValue `validate:"dive"`
132- // The filled template suffix params to be used for the test case. (optional)
146+ // The filled template suffix params to be used for template test cases.
147+ // For easy identification, we add a suffix to the filled test case title
148+ // For example, for a template with title "Template_title" and you provide SuffixParams as param1, param2
149+ // The generated filled test case will have title "Template_title (param1=val1, param2=val2)".
133150 FilledTCaseTitleSuffixParams []string `validate:"dive,max=255"`
134151 // The custom fields to be used for the test case. (optional)
135152 CustomFields map [string ]CustomFieldValue `validate:"dive,keys,max=64,endkeys,required"`
@@ -153,6 +170,8 @@ func NewQASphereCSV() *QASphereCSV {
153170 }
154171}
155172
173+ // AddCustomField adds a custom field to the QASphereCSV.
174+ // The custom fields need to pre-declared by using AddCustomField or AddCustomFields
156175func (q * QASphereCSV ) AddCustomField (cf CustomField ) error {
157176 if err := q .validate .Struct (cf ); err != nil {
158177 return errors .Wrap (err , "custom field validation" )
@@ -169,6 +188,7 @@ func (q *QASphereCSV) AddCustomField(cf CustomField) error {
169188 return nil
170189}
171190
191+ // AddCustomFields adds multiple custom fields to the QASphereCSV.
172192func (q * QASphereCSV ) AddCustomFields (cfs []CustomField ) error {
173193 var err error
174194 for _ , cf := range cfs {
@@ -178,7 +198,6 @@ func (q *QASphereCSV) AddCustomFields(cfs []CustomField) error {
178198 }
179199 return err
180200}
181-
182201func (q * QASphereCSV ) AddTestCase (tc TestCase ) error {
183202 if tc .Type == TestCaseType ("" ) {
184203 tc .Type = TestCaseTypeStandalone
0 commit comments