Repository: xanzy/go-gitlab
Pull request #983 (2020-11-25 14:18:31)

Add file, system_output, stack_trace, attachment_url
The fields `file`, `system_output`, `stack_trace`, `attachment_url` were
missing. As you can see in the api spec below, the fields can be string
on null.

Besides that, in `testdata/get_pipeline_testreport.json` the `classname`
had the value `null`, but that should not be possible according to the spec.

---

The api spec: https://gitlab.com/gitlab-org/gitlab-foss/-/blob/13-6-stable/spec/fixtures/api/schemas/entities/test_case.json
```
{
  "type": "object",
  "required" : [
    "status",
    "name"
  ],
  "properties": {
    "status": { "type": "string" },
    "name": { "type": "string" },
    "classname": { "type": "string" },
    "file": { "type": ["string", "null"] },
    "execution_time": { "type": "float" },
    "system_output": { "type": ["string", "null"] },
    "stack_trace":  { "type": ["string", "null"] },
    "attachment_url":  { "type": ["string", "null"] },
    "recent_failures": {
      "oneOf": [
        { "type": "null" },
        { "$ref": "test_case/recent_failures.json" }
      ]
    }
  },
  "additionalProperties": false
}
```

Related MR in which the `system_output` and `stack_trace` were removed: https://github.com/xanzy/go-gitlab/pull/947


Patch:
diff --git a/deployments.go b/deployments.go
index 7a0ca82..2855f91 100644
--- a/deployments.go
+++ b/deployments.go
@@ -53,12 +53,10 @@ type Deployment struct {
 		User       *User      `json:"user"`
 		Commit     *Commit    `json:"commit"`
 		Pipeline   struct {
-			ID        int        `json:"id"`
-			SHA       string     `json:"sha"`
-			Ref       string     `json:"ref"`
-			Status    string     `json:"status"`
-			CreatedAt *time.Time `json:"created_at"`
-			UpdatedAt *time.Time `json:"updated_at"`
+			ID     int    `json:"id"`
+			SHA    string `json:"sha"`
+			Ref    string `json:"ref"`
+			Status string `json:"status"`
 		} `json:"pipeline"`
 		Runner *Runner `json:"runner"`
 	} `json:"deployable"`
diff --git a/pipelines.go b/pipelines.go
index 5b89348..07427f9 100644
--- a/pipelines.go
+++ b/pipelines.go
@@ -108,7 +108,11 @@ type PipelineTestCases struct {
 	Status        string  `json:"status"`
 	Name          string  `json:"name"`
 	Classname     string  `json:"classname"`
+	File          string  `json:"file"`
 	ExecutionTime float64 `json:"execution_time"`
+	SystemOutput  string  `json:"system_output"`
+	StackTrace    string  `json:"stack_trace"`
+	AttachmentUrl string  `json:"attachment_url"`
 }
 
 func (p PipelineTestReport) String() string {


Test patch:
diff --git a/pipelines_test.go b/pipelines_test.go
index 96bf257..91beb64 100644
--- a/pipelines_test.go
+++ b/pipelines_test.go
@@ -102,27 +102,43 @@ func TestGetPipelineTestReport(t *testing.T) {
 					{
 						Status:        "error",
 						Name:          "Error testcase 1",
-						Classname:     "",
+						Classname:     "MyClassOne",
+						File:          "/path/file.ext",
 						ExecutionTime: 19.987,
+						SystemOutput:  "output message\n\noutput message 2",
+						StackTrace:    "java.lang.Exception: Stack trace\nat java.base/java.lang.Thread.dumpStack(Thread.java:1383)",
+						AttachmentUrl: "http://foo.bar",
 					},
 
 					{
 						Status:        "error",
 						Name:          "Error testcase 2",
-						Classname:     "",
+						Classname:     "MyClass",
+						File:          "",
 						ExecutionTime: 19.984,
+						SystemOutput:  "",
+						StackTrace:    "",
+						AttachmentUrl: "",
 					},
 					{
 						Status:        "error",
 						Name:          "Error testcase 3",
-						Classname:     "",
+						Classname:     "MyClass",
+						File:          "",
 						ExecutionTime: 0.0,
+						SystemOutput:  "Undefined message",
+						StackTrace:    "",
+						AttachmentUrl: "",
 					},
 					{
 						Status:        "success",
 						Name:          "Succes full testcase",
-						Classname:     "",
+						Classname:     "MyClass",
+						File:          "",
 						ExecutionTime: 19.7799999999999985,
+						SystemOutput:  "",
+						StackTrace:    "",
+						AttachmentUrl: "",
 					}},
 			},
 			{
@@ -136,8 +152,12 @@ func TestGetPipelineTestReport(t *testing.T) {
 				TestCases: []PipelineTestCases{{
 					Status:        "success",
 					Name:          "Succesfull testcase",
-					Classname:     "",
+					Classname:     "MyClass",
+					File:          "",
 					ExecutionTime: 1.008,
+					SystemOutput:  "",
+					StackTrace:    "",
+					AttachmentUrl: "",
 				}},
 			},
 		}}
diff --git a/testdata/get_pipeline_testreport.json b/testdata/get_pipeline_testreport.json
index 9975a61..0a0f68a 100644
--- a/testdata/get_pipeline_testreport.json
+++ b/testdata/get_pipeline_testreport.json
@@ -19,45 +19,36 @@
                 {
                     "status": "error",
                     "name": "Error testcase 1",
-                    "classname": null,
+                    "classname": "MyClassOne",
+                    "file": "/path/file.ext",
                     "execution_time": 19.987,
-                    "system_output": [
-                        {
-                            "message": "output message",
-                            "type": "pending"
-                        },
-                        {
-                            "message": "output message 2",
-                            "type": "skipped"
-                        }
-                    ],
-                    "stack_trace": null
+                    "system_output": "output message\n\noutput message 2",
+                    "stack_trace": "java.lang.Exception: Stack trace\nat java.base/java.lang.Thread.dumpStack(Thread.java:1383)",
+                    "attachment_url": "http://foo.bar"
                 },
                 {
                     "status": "error",
                     "name": "Error testcase 2",
-                    "classname": null,
+                    "classname": "MyClass",
+                    "file": null,
                     "execution_time": 19.984,
                     "system_output": null,
-                    "stack_trace": null
+                    "stack_trace": null,
+                    "attachment_url": null
                 },
                 {
                     "status": "error",
                     "name": "Error testcase 3",
-                    "classname": null,
+                    "classname": "MyClass",
+                    "file": null,
                     "execution_time": 0.0,
-                    "system_output":
-                        {
-                            "message": "Undefined message",
-                            "type": "undefined"
-                        }
-                    ,
-                    "stack_trace": null
+                    "system_output": "Undefined message"
                 },
                 {
                     "status": "success",
                     "name": "Succes full testcase",
-                    "classname": null,
+                    "classname": "MyClass",
+                    "file": null,
                     "execution_time": 19.7799999999999985,
                     "system_output": null,
                     "stack_trace": null
@@ -77,7 +68,8 @@
                 {
                     "status": "success",
                     "name": "Succesfull testcase",
-                    "classname": null,
+                    "classname": "MyClass",
+                    "file": null,
                     "execution_time": 1.008,
                     "system_output": null,
                     "stack_trace": null