Repository: xanzy/go-gitlab
Pull request #1518 (2022-08-08 17:41:09)

feat(jobs): add pipeline.project_id

svanharmelen: Please rebase to fix the failing checks...

Patch:
diff --git a/jobs.go b/jobs.go
index b238fc8..c70e120 100644
--- a/jobs.go
+++ b/jobs.go
@@ -48,10 +48,11 @@ type Job struct {
 	ID                int        `json:"id"`
 	Name              string     `json:"name"`
 	Pipeline          struct {
-		ID     int    `json:"id"`
-		Ref    string `json:"ref"`
-		Sha    string `json:"sha"`
-		Status string `json:"status"`
+		ID        int    `json:"id"`
+		ProjectID int    `json:"project_id"`
+		Ref       string `json:"ref"`
+		Sha       string `json:"sha"`
+		Status    string `json:"status"`
 	} `json:"pipeline"`
 	Ref       string `json:"ref"`
 	Artifacts []struct {


Test patch:
diff --git a/jobs_test.go b/jobs_test.go
index 9c39080..8a171a8 100644
--- a/jobs_test.go
+++ b/jobs_test.go
@@ -70,6 +70,7 @@ func TestJobsService_ListProjectJobs(t *testing.T) {
     "name": "teaspoon",
     "pipeline": {
       "id": 6,
+      "project_id": 1,
       "ref": "master",
       "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
       "status": "pending"
@@ -100,6 +101,7 @@ func TestJobsService_ListProjectJobs(t *testing.T) {
     "name": "rspec:other",
     "pipeline": {
       "id": 6,
+      "project_id": 1,
       "ref": "master",
       "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
       "status": "pending"
@@ -133,15 +135,17 @@ func TestJobsService_ListProjectJobs(t *testing.T) {
 			Name:         "teaspoon",
 			TagList:      []string{"docker runner", "ubuntu18"},
 			Pipeline: struct {
-				ID     int    `json:"id"`
-				Ref    string `json:"ref"`
-				Sha    string `json:"sha"`
-				Status string `json:"status"`
+				ID        int    `json:"id"`
+				ProjectID int    `json:"project_id"`
+				Ref       string `json:"ref"`
+				Sha       string `json:"sha"`
+				Status    string `json:"status"`
 			}{
-				ID:     6,
-				Ref:    "master",
-				Sha:    "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
-				Status: "pending",
+				ID:        6,
+				ProjectID: 1,
+				Ref:       "master",
+				Sha:       "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
+				Status:    "pending",
 			},
 			Ref:           "master",
 			Stage:         "test",
@@ -165,15 +169,17 @@ func TestJobsService_ListProjectJobs(t *testing.T) {
 			Name:         "rspec:other",
 			TagList:      []string{"docker runner", "win10-2004"},
 			Pipeline: struct {
-				ID     int    `json:"id"`
-				Ref    string `json:"ref"`
-				Sha    string `json:"sha"`
-				Status string `json:"status"`
+				ID        int    `json:"id"`
+				ProjectID int    `json:"project_id"`
+				Ref       string `json:"ref"`
+				Sha       string `json:"sha"`
+				Status    string `json:"status"`
 			}{
-				ID:     6,
-				Ref:    "master",
-				Sha:    "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
-				Status: "pending",
+				ID:        6,
+				ProjectID: 1,
+				Ref:       "master",
+				Sha:       "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
+				Status:    "pending",
 			},
 			Ref:    "master",
 			Stage:  "test",
diff --git a/runners_test.go b/runners_test.go
index 27faf18..ee8cfed 100644
--- a/runners_test.go
+++ b/runners_test.go
@@ -56,15 +56,17 @@ func TestListRunnersJobs(t *testing.T) {
 	}
 
 	pipeline := struct {
-		ID     int    `json:"id"`
-		Ref    string `json:"ref"`
-		Sha    string `json:"sha"`
-		Status string `json:"status"`
+		ID        int    `json:"id"`
+		ProjectID int    `json:"project_id"`
+		Ref       string `json:"ref"`
+		Sha       string `json:"sha"`
+		Status    string `json:"status"`
 	}{
-		ID:     8777,
-		Ref:    "master",
-		Sha:    "6c016b801a88f4bd31f927fc045b5c746a6f823e",
-		Status: "failed",
+		ID:        8777,
+		ProjectID: 3252,
+		Ref:       "master",
+		Sha:       "6c016b801a88f4bd31f927fc045b5c746a6f823e",
+		Status:    "failed",
 	}
 
 	want := []*Job{