From 9314fa638eab6432a61d5769b98d34ffbc5c8dbb Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 10 Apr 2024 23:46:05 +0200 Subject: [PATCH 1/2] fix: change products and powerups type in organization struct It looks like Trello changed this from a string value to an integer. I searched around in [their api docs](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-get) but couldn't really find anything about this so I just assumed int (not uint, int64, etc). --- organization.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/organization.go b/organization.go index 357bcf8..931cacd 100644 --- a/organization.go +++ b/organization.go @@ -13,14 +13,14 @@ import ( // https://developers.trello.com/reference/#organizations type Organization struct { client *Client - ID string `json:"id"` - Name string `json:"name"` - DisplayName string `json:"displayName"` - Desc string `json:"desc"` - URL string `json:"url"` - Website string `json:"website"` - Products []string `json:"products"` - PowerUps []string `json:"powerUps"` + ID string `json:"id"` + Name string `json:"name"` + DisplayName string `json:"displayName"` + Desc string `json:"desc"` + URL string `json:"url"` + Website string `json:"website"` + Products []int `json:"products"` + PowerUps []int `json:"powerUps"` } // GetOrganization takes an organization id and Arguments and either From 2f5278cb367df5835ce8b8217acc985de95baa7d Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 13 Apr 2024 13:30:45 +0200 Subject: [PATCH 2/2] chore(test): add realistic test data --- organization_test.go | 12 ++++++++++++ testdata/organizations/culturefoundry.json | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/organization_test.go b/organization_test.go index f2ea111..7fa652e 100644 --- a/organization_test.go +++ b/organization_test.go @@ -14,6 +14,18 @@ func TestGetOrganization(t *testing.T) { if organization.DisplayName != "Culture Foundry" { t.Errorf("Expected name 'Culture Foundry'. Got '%s'.", organization.DisplayName) } + if len(organization.PowerUps) != 1 { + t.Errorf("Expected PowerUps to have length of 1 but was %d", len(organization.PowerUps)) + } + if organization.PowerUps[0] != 42 { + t.Errorf("Expected first PowerUp to be %d but was %d", 42, organization.PowerUps[0]) + } + if len(organization.Products) != 1 { + t.Errorf("Expected Products to have length of 1 but was %d", len(organization.Products)) + } + if organization.Products[0] != 110 { + t.Errorf("Expected first Product to be %d but was %d", 110, organization.Products[0]) + } } func TestGetBoardsInOrganization(t *testing.T) { diff --git a/testdata/organizations/culturefoundry.json b/testdata/organizations/culturefoundry.json index 18936be..46d921a 100644 --- a/testdata/organizations/culturefoundry.json +++ b/testdata/organizations/culturefoundry.json @@ -7,6 +7,6 @@ "url": "https://trello.com/culturefoundry", "website": null, "logoHash": null, - "products": [], - "powerUps": [] + "products": [110], + "powerUps": [42] }