Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,11 @@ func (customActionsTriggerDefinition *CustomActionsTriggerDefinition) ExtendedTe
}
q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess.Nodes = append(q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess.Nodes, resp.Nodes...)
q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess.PageInfo = resp.PageInfo
q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess.TotalCount += resp.TotalCount
}
q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess.TotalCount = len(q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess.Nodes)
return &q.Account.CustomActionsTriggerDefinition.ExtendedTeamAccess, nil
}

type CustomActionsExternalActionsConnection struct {
Nodes []CustomActionsExternalAction
PageInfo PageInfo
TotalCount int
}

func (s *CustomActionsExternalActionsConnection) GetNodes() any {
return s.Nodes
}

type CustomActionsTriggerDefinitionsConnection struct {
Nodes []CustomActionsTriggerDefinition
PageInfo PageInfo
Expand Down Expand Up @@ -111,6 +101,7 @@ func (client *Client) ListCustomActions(variables *PayloadVariables) (*CustomAct
q.Account.Actions.Nodes = append(q.Account.Actions.Nodes, resp.Nodes...)
q.Account.Actions.PageInfo = resp.PageInfo
}
q.Account.Actions.TotalCount = len(q.Account.Actions.Nodes)
return &q.Account.Actions, nil
}

Expand Down
16 changes: 8 additions & 8 deletions actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ func TestCreateWebhookAction(t *testing.T) {
func TestListCustomActions(t *testing.T) {
// Arrange
testRequestOne := autopilot.NewTestRequest(
`query ExternalActionList($after:String!$first:Int!){account{customActionsExternalActions(after: $after, first: $first){nodes{{ template "custom_actions_request" }},{{ template "pagination_request" }},totalCount}}}`,
`query ExternalActionList($after:String!$first:Int!){account{customActionsExternalActions(after: $after, first: $first){nodes{{ template "custom_actions_request" }},{{ template "pagination_request" }}}}}`,
`{{ template "pagination_initial_query_variables" }}`,
`{ "data": { "account": { "customActionsExternalActions": { "nodes": [ { {{ template "custom_action1_response" }} }, { {{ template "custom_action2_response" }} } ], {{ template "pagination_initial_pageInfo_response" }}, "totalCount": 2 }}}}`,
`{ "data": { "account": { "customActionsExternalActions": { "nodes": [ { {{ template "custom_action1_response" }} }, { {{ template "custom_action2_response" }} } ], {{ template "pagination_initial_pageInfo_response" }} }}}}`,
)
testRequestTwo := autopilot.NewTestRequest(
`query ExternalActionList($after:String!$first:Int!){account{customActionsExternalActions(after: $after, first: $first){nodes{{ template "custom_actions_request" }},{{ template "pagination_request" }},totalCount}}}`,
`query ExternalActionList($after:String!$first:Int!){account{customActionsExternalActions(after: $after, first: $first){nodes{{ template "custom_actions_request" }},{{ template "pagination_request" }}}}}`,
`{{ template "pagination_second_query_variables" }}`,
`{ "data": { "account": { "customActionsExternalActions": { "nodes": [ { {{ template "custom_action3_response" }} } ], {{ template "pagination_second_pageInfo_response" }}, "totalCount": 1 }}}}`,
`{ "data": { "account": { "customActionsExternalActions": { "nodes": [ { {{ template "custom_action3_response" }} } ], {{ template "pagination_second_pageInfo_response" }} }}}}`,
)
requests := []autopilot.TestRequest{testRequestOne, testRequestTwo}

client := BestTestClient(t, "custom_actions/list_actions", requests...)
// Act
response, err := client.ListCustomActions(nil)
autopilot.Ok(t, err)
result := response.Nodes
// Assert
autopilot.Ok(t, err)
autopilot.Equals(t, 3, len(result))
autopilot.Equals(t, "Deploy Freeze", result[1].Name)
autopilot.Equals(t, "Page On-Call", result[2].Name)
Expand Down Expand Up @@ -352,12 +352,12 @@ func TestDeleteTriggerDefinition(t *testing.T) {
func TestListExtendedTeamAccess(t *testing.T) {
// Arrange
testRequestOne := autopilot.NewTestRequest(
`query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,managedAliases,contacts{address,displayName,displayType,externalId,id,isDefault,type},htmlUrl,manager{id,email,htmlUrl,name,provisionedBy,role},memberships{nodes{role,team{alias,id},user{id,email}},{{ template "pagination_request" }},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount}},{{ template "pagination_request" }},totalCount}}}}`,
`query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,managedAliases,contacts{address,displayName,displayType,externalId,id,isDefault,type},htmlUrl,manager{id,email,htmlUrl,name,provisionedBy,role},memberships{nodes{role,team{alias,id},user{id,email}},{{ template "pagination_request" }}},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},{{ template "pagination_request" }}}},{{ template "pagination_request" }}}}}}`,
`{{ template "extended_team_access_get_vars_1" }}`,
`{{ template "extended_team_access_response_1" }}`,
)
testRequestTwo := autopilot.NewTestRequest(
`query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,managedAliases,contacts{address,displayName,displayType,externalId,id,isDefault,type},htmlUrl,manager{id,email,htmlUrl,name,provisionedBy,role},memberships{nodes{role,team{alias,id},user{id,email}},{{ template "pagination_request" }},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount}},{{ template "pagination_request" }},totalCount}}}}`,
`query ExtendedTeamAccessList($after:String!$first:Int!$input:IdentifierInput!){account{customActionsTriggerDefinition(input: $input){extendedTeamAccess(after: $after, first: $first){nodes{alias,id,aliases,managedAliases,contacts{address,displayName,displayType,externalId,id,isDefault,type},htmlUrl,manager{id,email,htmlUrl,name,provisionedBy,role},memberships{nodes{role,team{alias,id},user{id,email}},{{ template "pagination_request" }}},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},{{ template "pagination_request" }}}},{{ template "pagination_request" }}}}}}`,
`{{ template "extended_team_access_get_vars_2" }}`,
`{{ template "extended_team_access_response_2" }}`,
)
Expand All @@ -372,10 +372,10 @@ func TestListExtendedTeamAccess(t *testing.T) {
if resp == nil || resp.Nodes == nil || len(resp.Nodes) == 0 {
t.Error("Expected team access response to not be nil")
}
autopilot.Ok(t, err)
result := resp.Nodes

// Assert
autopilot.Ok(t, err)
autopilot.Equals(t, "example", result[0].Alias)
autopilot.Equals(t, id1, result[0].Id)
}
Expand Down
4 changes: 2 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ func (cacher *Cacher) doCacheCategories(client *Client) {
func (cacher *Cacher) doCacheLevels(client *Client) {
log.Debug().Msg("Caching 'Level' lookup table from API ...")

data, dataErr := client.ListLevels()
data, dataErr := client.ListLevels(nil)
if dataErr != nil {
log.Warn().Msgf("===> Failed to list all 'Level' from API - REASON: %s", dataErr.Error())
}

for _, item := range data {
for _, item := range data.Nodes {
cacher.Levels[item.Alias] = item
}
}
Expand Down
14 changes: 7 additions & 7 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@ func TestCache(t *testing.T) {
`{"data":{"account":{ "systems":{ "nodes":[{{ template "system1_response" }}] } }}}`,
)
testRequestFour := autopilot.NewTestRequest(
`query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,managedAliases,contacts{address,displayName,displayType,externalId,id,isDefault,type},htmlUrl,manager{id,email,htmlUrl,name,provisionedBy,role},memberships{nodes{role,team{alias,id},user{id,email}},{{ template "pagination_request" }},totalCount},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount}},{{ template "pagination_request" }},totalCount}}}`,
`query TeamList($after:String!$first:Int!){account{teams(after: $after, first: $first){nodes{alias,id,aliases,managedAliases,contacts{address,displayName,displayType,externalId,id,isDefault,type},htmlUrl,manager{id,email,htmlUrl,name,provisionedBy,role},memberships{nodes{role,team{alias,id},user{id,email}},{{ template "pagination_request" }}},name,parentTeam{alias,id},responsibilities,tags{nodes{id,key,value},{{ template "pagination_request" }}}},{{ template "pagination_request" }}}}}`,
`{ "after": "", "first": 100 }`,
`{"data":{"account":{ "teams":{ "nodes":[{{ template "team_1" }}] } }}}`,
)
testRequestFive := autopilot.NewTestRequest(
`query CategoryList($after:String!$first:Int!){account{rubric{categories(after: $after, first: $first){nodes{description,id,name},{{ template "pagination_request" }},totalCount}}}}`,
`query CategoryList($after:String!$first:Int!){account{rubric{categories(after: $after, first: $first){nodes{description,id,name},{{ template "pagination_request" }}}}}}`,
`{ "after": "", "first": 100 }`,
`{"data":{"account":{"rubric":{ "categories":{ "nodes":[{{ template "category_1" }}] } }}}}`,
)
testRequestSix := autopilot.NewTestRequest(
`{account{rubric{levels{nodes{alias,description,id,index,name},{{ template "pagination_request" }},totalCount}}}}`,
`{}`,
`query LevelsList($after:String!$first:Int!){account{rubric{levels(after: $after, first: $first){nodes{alias,description,id,index,name},{{ template "pagination_request" }}}}}}`,
`{ "after": "", "first": 100 }`,
`{"data":{"account":{"rubric":{ "levels":{ "nodes":[{{ template "level_1" }}] } }}}}`,
)
testRequestSeven := autopilot.NewTestRequest(
`query FilterList($after:String!$first:Int!){account{filters(after: $after, first: $first){nodes{id,name,connective,htmlUrl,predicates{caseSensitive,key,keyData,type,value}},{{ template "pagination_request" }},totalCount}}}`,
`query FilterList($after:String!$first:Int!){account{filters(after: $after, first: $first){nodes{id,name,connective,htmlUrl,predicates{caseSensitive,key,keyData,type,value}},{{ template "pagination_request" }}}}}`,
`{ "after": "", "first": 100 }`,
`{"data":{"account":{ "filters":{ "nodes":[{{ template "filter_1" }}] } }}}`,
)
testRequestEight := autopilot.NewTestRequest(
`query IntegrationList($after:String!$first:Int!){account{integrations(after: $after, first: $first){nodes{{ template "integration_request" }},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}`,
`query IntegrationList($after:String!$first:Int!){account{integrations(after: $after, first: $first){nodes{{ template "integration_request" }},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor}}}}`,
`{ "after": "", "first": 100 }`,
`{"data":{"account":{ "integrations":{ "nodes":[{{ template "integration_1" }}] } }}}`,
)
testRequestNine := autopilot.NewTestRequest(
`query RepositoryList($after:String!$first:Int!$visible:Boolean!){account{repositories(after: $after, first: $first, visible: $visible){hiddenCount,nodes{archivedAt,createdOn,defaultAlias,defaultBranch,description,forked,htmlUrl,id,languages{name,usage},lastOwnerChangedAt,locked,name,organization,owner{alias,id},private,repoKey,services{edges{atRoot,node{id,aliases},paths{href,path},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},type,url,visible},organizationCount,ownedCount,{{ template "pagination_request" }},totalCount,visibleCount}}}`,
`query RepositoryList($after:String!$first:Int!$visible:Boolean!){account{repositories(after: $after, first: $first, visible: $visible){hiddenCount,nodes{archivedAt,createdOn,defaultAlias,defaultBranch,description,forked,htmlUrl,id,languages{name,usage},lastOwnerChangedAt,locked,name,organization,owner{alias,id},private,repoKey,services{edges{atRoot,node{id,aliases},paths{href,path},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }}},tags{nodes{id,key,value},{{ template "pagination_request" }}},tier{alias,description,id,index,name},type,url,visible},organizationCount,ownedCount,{{ template "pagination_request" }},visibleCount}}}`,
`{ "after": "", "first": 100, "visible": true }`,
`{"data":{"account":{ "repositories":{ "hiddenCount": 0, "nodes":[{{ template "repository_1" }}] } }}}`,
)
Expand Down
8 changes: 1 addition & 7 deletions category.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import (
"github.com/hasura/go-graphql-client"
)

type CategoryConnection struct {
Nodes []Category
PageInfo PageInfo
TotalCount int
}

func (category *Category) Alias() string {
return slug.Make(category.Name)
}
Expand Down Expand Up @@ -69,8 +63,8 @@ func (client *Client) ListCategories(variables *PayloadVariables) (*CategoryConn
}
q.Account.Rubric.Categories.Nodes = append(q.Account.Rubric.Categories.Nodes, resp.Nodes...)
q.Account.Rubric.Categories.PageInfo = resp.PageInfo
q.Account.Rubric.Categories.TotalCount += resp.TotalCount
}
q.Account.Rubric.Categories.TotalCount = len(q.Account.Rubric.Categories.Nodes)
return &q.Account.Rubric.Categories, nil
}

Expand Down
8 changes: 4 additions & 4 deletions category_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func TestGetMissingRubricCategory(t *testing.T) {
func TestListRubricCategories(t *testing.T) {
// Arrange
testRequestOne := autopilot.NewTestRequest(
`query CategoryList($after:String!$first:Int!){account{rubric{categories(after: $after, first: $first){nodes{description,id,name},{{ template "pagination_request" }},totalCount}}}}`,
`query CategoryList($after:String!$first:Int!){account{rubric{categories(after: $after, first: $first){nodes{description,id,name},{{ template "pagination_request" }}}}}}`,
`{{ template "pagination_initial_query_variables" }}`,
`{ "data": { "account": { "rubric": { "categories": { "nodes": [ { {{ template "rubric_categories_response1" }} }, { {{ template "rubric_categories_response2" }} } ], {{ template "pagination_initial_pageInfo_response" }}, "totalCount": 2 }}}}}`,
`{ "data": { "account": { "rubric": { "categories": { "nodes": [ { {{ template "rubric_categories_response1" }} }, { {{ template "rubric_categories_response2" }} } ], {{ template "pagination_initial_pageInfo_response" }} }}}}}`,
)
testRequestTwo := autopilot.NewTestRequest(
`query CategoryList($after:String!$first:Int!){account{rubric{categories(after: $after, first: $first){nodes{description,id,name},{{ template "pagination_request" }},totalCount}}}}`,
`query CategoryList($after:String!$first:Int!){account{rubric{categories(after: $after, first: $first){nodes{description,id,name},{{ template "pagination_request" }}}}}}`,
`{{ template "pagination_second_query_variables" }}`,
`{ "data": { "account": { "rubric": { "categories": { "nodes": [ { {{ template "rubric_categories_response3" }} } ], {{ template "pagination_second_pageInfo_response" }}, "totalCount": 1 }}}}}`,
`{ "data": { "account": { "rubric": { "categories": { "nodes": [ { {{ template "rubric_categories_response3" }} } ], {{ template "pagination_second_pageInfo_response" }} }}}}}`,
)
requests := []autopilot.TestRequest{testRequestOne, testRequestTwo}

Expand Down
8 changes: 1 addition & 7 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ func UnmarshalCheckUpdateInput(checkType CheckType, data []byte) (any, error) {
return output, nil
}

type CheckConnection struct {
Nodes []Check
PageInfo PageInfo
TotalCount int
}

type CheckCreateInputProvider interface {
GetCheckCreateInput() *CheckCreateInput
}
Expand Down Expand Up @@ -210,8 +204,8 @@ func (client *Client) ListChecks(variables *PayloadVariables) (*CheckConnection,
}
q.Account.Rubric.Checks.Nodes = append(q.Account.Rubric.Checks.Nodes, resp.Nodes...)
q.Account.Rubric.Checks.PageInfo = resp.PageInfo
q.Account.Rubric.Checks.TotalCount += resp.TotalCount
}
q.Account.Rubric.Checks.TotalCount = len(q.Account.Rubric.Checks.Nodes)
return &q.Account.Rubric.Checks, nil
}

Expand Down
Loading
Loading