Verified Commit bf664361 authored by José M. Requena Plens's avatar José M. Requena Plens Committed by GitLab
Browse files

feat(topics): add OrganizationID to the Topic struct

Changelog: Improvements
parent 5e38b31d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ type Topic struct {
	Description        string `json:"description"`
	TotalProjectsCount uint64 `json:"total_projects_count"`
	AvatarURL          string `json:"avatar_url"`
	// Experimental field - may change outside of major releases
	OrganizationID int64 `json:"organization_id"`
}

func (t Topic) String() string {
+26 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ func TestTopicsService_ListTopics(t *testing.T) {
        "title": "GitLab",
        "description": "GitLab is a version control system",
        "total_projects_count": 1000,
        "organization_id": 1,
        "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon"
      },
      {
@@ -45,6 +46,7 @@ func TestTopicsService_ListTopics(t *testing.T) {
        "title": "Git",
        "description": "Git is free and open source",
        "total_projects_count": 900,
        "organization_id": 1,
        "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
      },
      {
@@ -53,6 +55,7 @@ func TestTopicsService_ListTopics(t *testing.T) {
        "title": "Git LFS",
        "description": null,
        "total_projects_count": 300,
        "organization_id": 2,
        "avatar_url": null
      }
    ]`)
@@ -68,6 +71,7 @@ func TestTopicsService_ListTopics(t *testing.T) {
		Title:              "GitLab",
		Description:        "GitLab is a version control system",
		TotalProjectsCount: 1000,
		OrganizationID:     1,
		AvatarURL:          "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
	}, {
		ID:                 3,
@@ -75,12 +79,14 @@ func TestTopicsService_ListTopics(t *testing.T) {
		Title:              "Git",
		Description:        "Git is free and open source",
		TotalProjectsCount: 900,
		OrganizationID:     1,
		AvatarURL:          "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
	}, {
		ID:                 2,
		Name:               "git-lfs",
		Title:              "Git LFS",
		TotalProjectsCount: 300,
		OrganizationID:     2,
	}}
	assert.Equal(t, want, topics)
}
@@ -97,6 +103,7 @@ func TestTopicsService_GetTopic(t *testing.T) {
      "title": "GitLab",
      "Description": "GitLab is a version control system",
      "total_projects_count": 1000,
      "organization_id": 1,
      "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon"
    }`)
	})
@@ -110,6 +117,7 @@ func TestTopicsService_GetTopic(t *testing.T) {
		Title:              "GitLab",
		Description:        "GitLab is a version control system",
		TotalProjectsCount: 1000,
		OrganizationID:     1,
		AvatarURL:          "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
	}
	assert.Equal(t, want, release)
@@ -127,6 +135,7 @@ func TestTopicsService_CreateTopic(t *testing.T) {
      "title": "Topic 1",
      "description": "description",
      "total_projects_count": 0,
      "organization_id": 1,
      "avatar_url": null
    }`)
	})
@@ -135,7 +144,14 @@ func TestTopicsService_CreateTopic(t *testing.T) {
	release, _, err := client.Topics.CreateTopic(opt)
	assert.NoError(t, err)

	want := &Topic{ID: 1, Name: "topic1", Title: "Topic 1", Description: "description", TotalProjectsCount: 0}
	want := &Topic{
		ID:                 1,
		Name:               "topic1",
		Title:              "Topic 1",
		Description:        "description",
		TotalProjectsCount: 0,
		OrganizationID:     1,
	}
	assert.Equal(t, want, release)
}

@@ -151,6 +167,7 @@ func TestTopicsService_UpdateTopic(t *testing.T) {
      "title": "Topic 1",
      "description": "description",
      "total_projects_count": 0,
      "organization_id": 1,
      "avatar_url": null
    }`)
	})
@@ -159,6 +176,13 @@ func TestTopicsService_UpdateTopic(t *testing.T) {
	release, _, err := client.Topics.UpdateTopic(1, opt)
	assert.NoError(t, err)

	want := &Topic{ID: 1, Name: "topic1", Title: "Topic 1", Description: "description", TotalProjectsCount: 0}
	want := &Topic{
		ID:                 1,
		Name:               "topic1",
		Title:              "Topic 1",
		Description:        "description",
		TotalProjectsCount: 0,
		OrganizationID:     1,
	}
	assert.Equal(t, want, release)
}