From 9bc7f41a5e57533812941723280177055617b4a8 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Mon, 16 Oct 2023 15:56:09 -0500 Subject: [PATCH 1/4] add ParentTeam field to Team, TeamCreateInput, TeamUpdateInput - tests updated --- actions_test.go | 4 +- cache_test.go | 2 +- group_test.go | 8 +- team.go | 3 + team_test.go | 161 +++++++++++++++++- testdata/fixtures/team/create_request.json | 29 ---- testdata/fixtures/team/create_response.json | 59 ------- testdata/fixtures/team/get_request.json | 10 +- .../fixtures/team/get_with_alias_request.json | 8 +- testdata/fixtures/team/update_request.json | 13 -- testdata/fixtures/team/update_response.json | 73 -------- 11 files changed, 174 insertions(+), 196 deletions(-) delete mode 100644 testdata/fixtures/team/create_request.json delete mode 100644 testdata/fixtures/team/create_response.json delete mode 100644 testdata/fixtures/team/update_request.json delete mode 100644 testdata/fixtures/team/update_response.json diff --git a/actions_test.go b/actions_test.go index 748dc659..968e6447 100644 --- a/actions_test.go +++ b/actions_test.go @@ -348,12 +348,12 @@ func TestDeleteTriggerDefinition(t *testing.T) { func TestListExtendedTeamAccess(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{{ template "extended_team_access_get_vars_1" }}`, `{{ template "extended_team_access_response_1" }}`, ) testRequestTwo := NewTestRequest( - `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{{ template "extended_team_access_get_vars_2" }}`, `{{ template "extended_team_access_response_2" }}`, ) diff --git a/cache_test.go b/cache_test.go index e57534db..e4d168af 100644 --- a/cache_test.go +++ b/cache_test.go @@ -20,7 +20,7 @@ func TestCache(t *testing.T) { `{"data":{"account":{ "lifecycles":[{{ template "lifecycle_1" }}] }}}`, ) testRequestThree := NewTestRequest( - `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{ "after": "", "first": 100 }`, `{"data":{"account":{ "teams":{ "nodes":[{{ template "team_1" }}] } }}}`, ) diff --git a/group_test.go b/group_test.go index d2932159..258d1a4e 100644 --- a/group_test.go +++ b/group_test.go @@ -64,12 +64,12 @@ func TestDeleteGroupWithAlias(t *testing.T) { func TestChildTeams(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "first_page_variables" }}, "group": "123456789" }`, `{ "data": { "account": { "group": { "childTeams": { "nodes": [ {{ template "team_1" }}, {{ template "team_2" }} ], {{ template "pagination_initial_pageInfo_response" }}, "totalCount": 2 }}}}}`, ) testRequestTwo := NewTestRequest( - `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "second_page_variables" }}, "group": "123456789" }`, `{ "data": { "account": { "group": { "childTeams": { "nodes": [ {{ template "team_3" }} ], {{ template "pagination_second_pageInfo_response" }}, "totalCount": 1 }}}}}`, ) @@ -94,12 +94,12 @@ func TestChildTeams(t *testing.T) { func TestDescendantTeams(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "first_page_variables" }}, "group": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvMTI" }`, `{ "data": { "account": { "group": { "descendantTeams": { "nodes": [ {{ template "team_1" }}, {{ template "team_2" }} ], {{ template "pagination_initial_pageInfo_response" }}, "totalCount": 2 }}}}}`, ) testRequestTwo := NewTestRequest( - `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "second_page_variables" }}, "group": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvMTI" }`, `{ "data": { "account": { "group": { "descendantTeams": { "nodes": [ {{ template "team_3" }} ], {{ template "pagination_second_pageInfo_response" }}, "totalCount": 1 }}}}}`, ) diff --git a/team.go b/team.go index b74ae45e..7592f7c7 100644 --- a/team.go +++ b/team.go @@ -53,6 +53,7 @@ type Team struct { Manager User Members *UserConnection Name string + ParentTeam *IdentifierInput Responsibilities string Tags *TagConnection } @@ -76,6 +77,7 @@ type TeamCreateInput struct { Responsibilities string `json:"responsibilities,omitempty"` Group *IdentifierInput `json:"group"` Contacts *[]ContactInput `json:"contacts,omitempty"` + ParentTeam *IdentifierInput `json:"parentTeam,omitempty"` } type TeamUpdateInput struct { @@ -85,6 +87,7 @@ type TeamUpdateInput struct { ManagerEmail string `json:"managerEmail,omitempty"` Group *IdentifierInput `json:"group"` Responsibilities string `json:"responsibilities,omitempty"` + ParentTeam *IdentifierInput `json:"parentTeam,omitempty"` } type TeamDeleteInput struct { diff --git a/team_test.go b/team_test.go index d2c37ae1..683bb3b2 100644 --- a/team_test.go +++ b/team_test.go @@ -20,7 +20,73 @@ func getWithAliasTestClient(t *testing.T) *ol.Client { func TestCreateTeam(t *testing.T) { // Arrange - client := ATestClient(t, "team/create") + testRequest := NewTestRequest( + `"mutation TeamCreate($input:TeamCreateInput!){teamCreate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}"`, + `{"input": {"name": "Example", "managerEmail": "john@example.com", "parentTeam": {"alias": "parent_team"}, "responsibilities": "Foo & bar", "group": {"alias": "test_group"}, "contacts": [ {"type": "slack_handle", "address": "@mozzie"}, {"type": "slack", "displayName": "", "address": "#general"}, {"type": "web", "displayName": "Homepage", "address": "https://example.com"} ] }}`, + `{ "data": { + "teamCreate": { + "team": { + "alias": "example", + "id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzY", + "aliases": [ + "example" + ], + "contacts": [ + { + "address": "#general", + "displayName": "", + "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNTk", + "type": "slack" + }, + { + "address": "https://example.com", + "displayName": "Homepage", + "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNjA", + "type": "web" + } + ], + "group": { + "id": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvNTI", + "alias": "test_group" + }, + "htmlUrl": "https://app.opslevel-staging.com/teams/example", + "manager": { + "email": "john@example.com", + "htmlUrl": "https://app.opslevel-staging.com/users/410", + "id": "Z2lkOi8vb3BzbGV2ZWwvVXNlci80MTA", + "name": "John Example", + "role": "admin" + }, + "members": { + "nodes": [ + { + "email": "john@example.com", + "htmlUrl": "https://app.opslevel-staging.com/users/410", + "id": "Z2lkOi8vb3BzbGV2ZWwvVXNlci80MTA", + "name": "John Example", + "role": "admin" + } + ], + "pageInfo": { + "hasNextPage": false, + "hasPreviousPage": false, + "startCursor": "MQ", + "endCursor": "MQ" + } + }, + "name": "Example", + "parentTeam": { + "id": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3", + "alias": "parent_team" + }, + "responsibilities": "Foo & bar" + }, + "errors": [] + }}}`, + ) + + client := BestTestClient(t, "team/create", testRequest) + // client := ATestClient(t, "team/create") // Act contacts := []ol.ContactInput{ ol.CreateContactSlackHandle("@mozzie", ol.NullString()), @@ -33,6 +99,7 @@ func TestCreateTeam(t *testing.T) { Responsibilities: "Foo & bar", Contacts: &contacts, Group: ol.NewIdentifier("test_group"), + ParentTeam: ol.NewIdentifier("parent_team"), }) // Assert autopilot.Ok(t, err) @@ -40,6 +107,7 @@ func TestCreateTeam(t *testing.T) { autopilot.Equals(t, "john@example.com", result.Manager.Email) autopilot.Equals(t, "Foo & bar", result.Responsibilities) autopilot.Equals(t, "test_group", result.Group.Alias) + autopilot.Equals(t, "parent_team", result.ParentTeam.Alias) } func TestGetTeam(t *testing.T) { @@ -133,7 +201,7 @@ func TestGetTeamWithAlias(t *testing.T) { func TestListTeams(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{{ template "pagination_initial_query_variables" }}`, `{ "data": { "account": { @@ -220,7 +288,7 @@ func TestListTeams(t *testing.T) { }}}}`, ) testRequestTwo := NewTestRequest( - `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{{ template "pagination_second_query_variables" }}`, `{ "data": { "account": { @@ -300,7 +368,7 @@ func TestListTeams(t *testing.T) { func TestListTeamsWithManager(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{ "after": "", "first": 100, "email": "kyle@opslevel.com" }`, `{ "data": { "account": { @@ -387,7 +455,7 @@ func TestListTeamsWithManager(t *testing.T) { }}}}`, ) testRequestTwo := NewTestRequest( - `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{ "after": "OA", "first": 100, "email": "kyle@opslevel.com" }`, `{ "data": { "account": { @@ -466,13 +534,93 @@ func TestListTeamsWithManager(t *testing.T) { func TestUpdateTeam(t *testing.T) { // Arrange - client := ATestClient(t, "team/update") + testRequest := NewTestRequest( + `"mutation TeamUpdate($input:TeamUpdateInput!){teamUpdate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}"`, + `{"input": {"id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ", "managerEmail": "ken@example.com", "responsibilities": "Foo & bar", "parentTeam": {"alias": "parent_team"}, "group": {"alias": "test_group" }}}`, + `{ "data": { + "teamUpdate": { + "team": { + "alias": "example", + "id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ", + "aliases": [ + "example" + ], + "contacts": [ + { + "address": "#general", + "displayName": "", + "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNTgy", + "type": "slack" + }, + { + "address": "https://example.com", + "displayName": "Homepage", + "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNTgz", + "type": "web" + } + ], + "group": { + "id": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvNTI", + "alias": "test_group" + }, + "htmlUrl": "https://app.opslevel.com/teams/example", + "manager": { + "email": "ken@example.com", + "htmlUrl": "https://app.opslevel.com/users/1099", + "id": "Z2lkOi7vb3BzbBV2ZWwvVXNlci8xMDk3", + "name": "Ken Example", + "role": "user" + }, + "members": { + "nodes": [ + { + "email": "kyle@example.com", + "htmlUrl": "https://app.opslevel.com/users/1097", + "id": "Z2lkOiBvb38zbGV2ZWwvVXNlci8xMDk3", + "name": "Kyle Example", + "role": "admin" + }, + { + "email": "john@example.com", + "htmlUrl": "https://app.opslevel.com/users/1098", + "id": "Z2lkOi8vb3BzbGV2ZWwvVXNlci8xMDk3", + "name": "John Example", + "role": "admin" + }, + { + "email": "ken@example.com", + "htmlUrl": "https://app.opslevel.com/users/1099", + "id": "Z2lkOi7vb3BzbBV2ZWwvVXNlci8xMDk3", + "name": "Ken Example", + "role": "user" + } + ], + "pageInfo": { + "hasNextPage": false, + "hasPreviousPage": false, + "startCursor": "MQ", + "endCursor": "MQ" + } + }, + "parentTeam": { + "id": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3", + "alias": "parent_team" + }, + "name": "Example", + "responsibilities": "Foo & bar" + }, + "errors": [] + }}}`, + ) + client := BestTestClient(t, "team/update", testRequest) + // client := ATestClient(t, "team/update") // Act result, err := client.UpdateTeam(ol.TeamUpdateInput{ Id: "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ", ManagerEmail: "ken@example.com", Responsibilities: "Foo & bar", Group: ol.NewIdentifier("test_group"), + ParentTeam: ol.NewIdentifier("parent_team"), }) // Assert autopilot.Ok(t, err) @@ -480,6 +628,7 @@ func TestUpdateTeam(t *testing.T) { autopilot.Equals(t, "ken@example.com", result.Manager.Email) autopilot.Equals(t, "Foo & bar", result.Responsibilities) autopilot.Equals(t, "test_group", result.Group.Alias) + autopilot.Equals(t, "parent_team", result.ParentTeam.Alias) } func TestDeleteTeam(t *testing.T) { diff --git a/testdata/fixtures/team/create_request.json b/testdata/fixtures/team/create_request.json deleted file mode 100644 index c7888aae..00000000 --- a/testdata/fixtures/team/create_request.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "query":"mutation TeamCreate($input:TeamCreateInput!){teamCreate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}", - "variables":{ - "input":{ - "name":"Example", - "managerEmail":"john@example.com", - "responsibilities":"Foo & bar", - "group":{ - "alias": "test_group" - }, - "contacts":[ - { - "type":"slack_handle", - "address":"@mozzie" - }, - { - "type":"slack", - "displayName":"", - "address":"#general" - }, - { - "type":"web", - "displayName":"Homepage", - "address":"https://example.com" - } - ] - } - } -} \ No newline at end of file diff --git a/testdata/fixtures/team/create_response.json b/testdata/fixtures/team/create_response.json deleted file mode 100644 index 876c7c76..00000000 --- a/testdata/fixtures/team/create_response.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "data": { - "teamCreate": { - "team": { - "alias": "example", - "id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzY", - "aliases": [ - "example" - ], - "contacts": [ - { - "address": "#general", - "displayName": "", - "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNTk", - "type": "slack" - }, - { - "address": "https://example.com", - "displayName": "Homepage", - "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNjA", - "type": "web" - } - ], - "group": { - "id": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvNTI", - "alias": "test_group" - }, - "htmlUrl": "https://app.opslevel-staging.com/teams/example", - "manager": { - "email": "john@example.com", - "htmlUrl": "https://app.opslevel-staging.com/users/410", - "id": "Z2lkOi8vb3BzbGV2ZWwvVXNlci80MTA", - "name": "John Example", - "role": "admin" - }, - "members": { - "nodes": [ - { - "email": "john@example.com", - "htmlUrl": "https://app.opslevel-staging.com/users/410", - "id": "Z2lkOi8vb3BzbGV2ZWwvVXNlci80MTA", - "name": "John Example", - "role": "admin" - } - ], - "pageInfo": { - "hasNextPage": false, - "hasPreviousPage": false, - "startCursor": "MQ", - "endCursor": "MQ" - } - }, - "name": "Example", - "responsibilities": "Foo & bar" - }, - "errors": [] - } - } -} \ No newline at end of file diff --git a/testdata/fixtures/team/get_request.json b/testdata/fixtures/team/get_request.json index cc821efc..90cac15d 100644 --- a/testdata/fixtures/team/get_request.json +++ b/testdata/fixtures/team/get_request.json @@ -1,6 +1,6 @@ { - "query":"query TeamGet($id:ID!){account{team(id: $id){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", - "variables":{ - "id":"Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ" - } -} \ No newline at end of file + "query": "query TeamGet($id:ID!){account{team(id: $id){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", + "variables": { + "id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ" + } +} diff --git a/testdata/fixtures/team/get_with_alias_request.json b/testdata/fixtures/team/get_with_alias_request.json index 5920e981..31a445c9 100644 --- a/testdata/fixtures/team/get_with_alias_request.json +++ b/testdata/fixtures/team/get_with_alias_request.json @@ -1,6 +1,6 @@ { - "query":"query TeamGet($alias:String!){account{team(alias: $alias){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", - "variables":{ - "alias":"example" + "query": "query TeamGet($alias:String!){account{team(alias: $alias){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", + "variables": { + "alias": "example" } -} \ No newline at end of file +} diff --git a/testdata/fixtures/team/update_request.json b/testdata/fixtures/team/update_request.json deleted file mode 100644 index 4adb0053..00000000 --- a/testdata/fixtures/team/update_request.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "query":"mutation TeamUpdate($input:TeamUpdateInput!){teamUpdate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}", - "variables":{ - "input":{ - "id":"Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ", - "managerEmail":"ken@example.com", - "responsibilities": "Foo & bar", - "group":{ - "alias": "test_group" - } - } - } -} diff --git a/testdata/fixtures/team/update_response.json b/testdata/fixtures/team/update_response.json deleted file mode 100644 index 67a0f8f0..00000000 --- a/testdata/fixtures/team/update_response.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "data": { - "teamUpdate": { - "team": { - "alias": "example", - "id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ", - "aliases": [ - "example" - ], - "contacts": [ - { - "address": "#general", - "displayName": "", - "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNTgy", - "type": "slack" - }, - { - "address": "https://example.com", - "displayName": "Homepage", - "id": "Z2lkOi8vb3BzbGV2ZWwvQ29udGFjdC8xNTgz", - "type": "web" - } - ], - "group": { - "id": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvNTI", - "alias": "test_group" - }, - "htmlUrl": "https://app.opslevel.com/teams/example", - "manager": { - "email": "ken@example.com", - "htmlUrl": "https://app.opslevel.com/users/1099", - "id": "Z2lkOi7vb3BzbBV2ZWwvVXNlci8xMDk3", - "name": "Ken Example", - "role": "user" - }, - "members": { - "nodes": [ - { - "email": "kyle@example.com", - "htmlUrl": "https://app.opslevel.com/users/1097", - "id": "Z2lkOiBvb38zbGV2ZWwvVXNlci8xMDk3", - "name": "Kyle Example", - "role": "admin" - }, - { - "email": "john@example.com", - "htmlUrl": "https://app.opslevel.com/users/1098", - "id": "Z2lkOi8vb3BzbGV2ZWwvVXNlci8xMDk3", - "name": "John Example", - "role": "admin" - }, - { - "email": "ken@example.com", - "htmlUrl": "https://app.opslevel.com/users/1099", - "id": "Z2lkOi7vb3BzbBV2ZWwvVXNlci8xMDk3", - "name": "Ken Example", - "role": "user" - } - ], - "pageInfo": { - "hasNextPage": false, - "hasPreviousPage": false, - "startCursor": "MQ", - "endCursor": "MQ" - } - }, - "name": "Example", - "responsibilities": "Foo & bar" - }, - "errors": [] - } - } - } \ No newline at end of file From ce71ec126aa369c08e83c89cab0c2541f8c6365d Mon Sep 17 00:00:00 2001 From: David Bloss Date: Mon, 16 Oct 2023 15:59:29 -0500 Subject: [PATCH 2/4] add changie log --- .changes/unreleased/Feature-20231016-155902.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changes/unreleased/Feature-20231016-155902.yaml diff --git a/.changes/unreleased/Feature-20231016-155902.yaml b/.changes/unreleased/Feature-20231016-155902.yaml new file mode 100644 index 00000000..f11b4826 --- /dev/null +++ b/.changes/unreleased/Feature-20231016-155902.yaml @@ -0,0 +1,3 @@ +kind: Feature +body: add ParentTeam field to Team, TeamCreateInput, and TeamUpdateInput +time: 2023-10-16T15:59:02.599001-05:00 From 6406430140f5ea44e89cfe16aca30bd94b862a63 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Mon, 16 Oct 2023 16:06:28 -0500 Subject: [PATCH 3/4] fix test after rebase --- team_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/team_test.go b/team_test.go index b0aaec0f..fdb7a179 100644 --- a/team_test.go +++ b/team_test.go @@ -10,7 +10,7 @@ import ( // TODO: not sure if there is a better way to handle reusing a client // Probably should be a feature of autopilot var testRequestWithAlias = NewTestRequest( - `"query TeamGet($alias:String!){account{team(alias: $alias){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query TeamGet($alias:String!){account{team(alias: $alias){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{"alias":"example"}`, `{ "data": { "account": { @@ -199,7 +199,7 @@ func TestCreateTeam(t *testing.T) { func TestGetTeam(t *testing.T) { // Arrange testRequest := NewTestRequest( - `"query TeamGet($id:ID!){account{team(id: $id){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query TeamGet($id:ID!){account{team(id: $id){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ "id":"Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ" }`, `{ "data": { "account": { From bc6289d28d4cb0fd0f122c28a7797e36c79537eb Mon Sep 17 00:00:00 2001 From: David Bloss Date: Tue, 17 Oct 2023 11:01:43 -0500 Subject: [PATCH 4/4] update ParentTeam struct tag type and tests --- actions_test.go | 4 ++-- cache_test.go | 2 +- group_test.go | 8 ++++---- team.go | 3 ++- team_test.go | 16 ++++++++-------- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/actions_test.go b/actions_test.go index 968e6447..96a07e05 100644 --- a/actions_test.go +++ b/actions_test.go @@ -348,12 +348,12 @@ func TestDeleteTriggerDefinition(t *testing.T) { func TestListExtendedTeamAccess(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{{ template "extended_team_access_get_vars_1" }}`, `{{ template "extended_team_access_response_1" }}`, ) testRequestTwo := NewTestRequest( - `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{{ template "extended_team_access_get_vars_2" }}`, `{{ template "extended_team_access_response_2" }}`, ) diff --git a/cache_test.go b/cache_test.go index e4d168af..b575514e 100644 --- a/cache_test.go +++ b/cache_test.go @@ -20,7 +20,7 @@ func TestCache(t *testing.T) { `{"data":{"account":{ "lifecycles":[{{ template "lifecycle_1" }}] }}}`, ) testRequestThree := NewTestRequest( - `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{ "after": "", "first": 100 }`, `{"data":{"account":{ "teams":{ "nodes":[{{ template "team_1" }}] } }}}`, ) diff --git a/group_test.go b/group_test.go index 258d1a4e..be68adcc 100644 --- a/group_test.go +++ b/group_test.go @@ -64,12 +64,12 @@ func TestDeleteGroupWithAlias(t *testing.T) { func TestChildTeams(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "first_page_variables" }}, "group": "123456789" }`, `{ "data": { "account": { "group": { "childTeams": { "nodes": [ {{ template "team_1" }}, {{ template "team_2" }} ], {{ template "pagination_initial_pageInfo_response" }}, "totalCount": 2 }}}}}`, ) testRequestTwo := NewTestRequest( - `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupChildTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){childTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "second_page_variables" }}, "group": "123456789" }`, `{ "data": { "account": { "group": { "childTeams": { "nodes": [ {{ template "team_3" }} ], {{ template "pagination_second_pageInfo_response" }}, "totalCount": 1 }}}}}`, ) @@ -94,12 +94,12 @@ func TestChildTeams(t *testing.T) { func TestDescendantTeams(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "first_page_variables" }}, "group": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvMTI" }`, `{ "data": { "account": { "group": { "descendantTeams": { "nodes": [ {{ template "team_1" }}, {{ template "team_2" }} ], {{ template "pagination_initial_pageInfo_response" }}, "totalCount": 2 }}}}}`, ) testRequestTwo := NewTestRequest( - `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query GroupDescendantTeamsList($after:String!$first:Int!$group:ID!){account{group(id: $group){descendantTeams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ {{ template "second_page_variables" }}, "group": "Z2lkOi8vb3BzbGV2ZWwvTmFtZXNwYWNlczo6R3JvdXAvMTI" }`, `{ "data": { "account": { "group": { "descendantTeams": { "nodes": [ {{ template "team_3" }} ], {{ template "pagination_second_pageInfo_response" }}, "totalCount": 1 }}}}}`, ) diff --git a/team.go b/team.go index de8704d5..279574f1 100644 --- a/team.go +++ b/team.go @@ -38,6 +38,7 @@ type ContactDeleteInput struct { Id ID `json:"id"` } +// Has no json struct tags as this is nested in returned data structs type TeamId struct { Alias string Id ID @@ -53,7 +54,7 @@ type Team struct { Manager User Members *UserConnection Name string - ParentTeam *IdentifierInput + ParentTeam *TeamId Responsibilities string Tags *TagConnection } diff --git a/team_test.go b/team_test.go index fdb7a179..4e5e914d 100644 --- a/team_test.go +++ b/team_test.go @@ -10,7 +10,7 @@ import ( // TODO: not sure if there is a better way to handle reusing a client // Probably should be a feature of autopilot var testRequestWithAlias = NewTestRequest( - `"query TeamGet($alias:String!){account{team(alias: $alias){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query TeamGet($alias:String!){account{team(alias: $alias){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{"alias":"example"}`, `{ "data": { "account": { @@ -107,7 +107,7 @@ var testRequestWithAlias = NewTestRequest( func TestCreateTeam(t *testing.T) { // Arrange testRequest := NewTestRequest( - `"mutation TeamCreate($input:TeamCreateInput!){teamCreate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}"`, + `"mutation TeamCreate($input:TeamCreateInput!){teamCreate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}"`, `{"input": {"name": "Example", "managerEmail": "john@example.com", "parentTeam": {"alias": "parent_team"}, "responsibilities": "Foo & bar", "group": {"alias": "test_group"}, "contacts": [ {"type": "slack_handle", "address": "@mozzie"}, {"type": "slack", "displayName": "", "address": "#general"}, {"type": "web", "displayName": "Homepage", "address": "https://example.com"} ] }}`, `{ "data": { "teamCreate": { @@ -199,7 +199,7 @@ func TestCreateTeam(t *testing.T) { func TestGetTeam(t *testing.T) { // Arrange testRequest := NewTestRequest( - `"query TeamGet($id:ID!){account{team(id: $id){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, + `"query TeamGet($id:ID!){account{team(id: $id){alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}"`, `{ "id":"Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ" }`, `{ "data": { "account": { @@ -382,7 +382,7 @@ func TestGetTeamWithAlias(t *testing.T) { func TestListTeams(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{{ template "pagination_initial_query_variables" }}`, `{ "data": { "account": { @@ -469,7 +469,7 @@ func TestListTeams(t *testing.T) { }}}}`, ) testRequestTwo := NewTestRequest( - `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{{ template "pagination_second_query_variables" }}`, `{ "data": { "account": { @@ -549,7 +549,7 @@ func TestListTeams(t *testing.T) { func TestListTeamsWithManager(t *testing.T) { // Arrange testRequestOne := NewTestRequest( - `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{ "after": "", "first": 100, "email": "kyle@opslevel.com" }`, `{ "data": { "account": { @@ -636,7 +636,7 @@ func TestListTeamsWithManager(t *testing.T) { }}}}`, ) testRequestTwo := NewTestRequest( - `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, + `"query TeamList($after:String!$email:String!$first:Int!){account{teams(managerEmail: $email, after: $after, first: $first){nodes{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}"`, `{ "after": "OA", "first": 100, "email": "kyle@opslevel.com" }`, `{ "data": { "account": { @@ -716,7 +716,7 @@ func TestListTeamsWithManager(t *testing.T) { func TestUpdateTeam(t *testing.T) { // Arrange testRequest := NewTestRequest( - `"mutation TeamUpdate($input:TeamUpdateInput!){teamUpdate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{id,alias},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}"`, + `"mutation TeamUpdate($input:TeamUpdateInput!){teamUpdate(input: $input){team{alias,id,aliases,contacts{address,displayName,id,type},group{alias,id},htmlUrl,manager{id,email,htmlUrl,name,role},members{nodes{id,email,htmlUrl,name,role},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}},errors{message,path}}}"`, `{"input": {"id": "Z2lkOi8vb3BzbGV2ZWwvVGVhbS83NzQ", "managerEmail": "ken@example.com", "responsibilities": "Foo & bar", "parentTeam": {"alias": "parent_team"}, "group": {"alias": "test_group" }}}`, `{ "data": { "teamUpdate": {