Skip to content

Commit

Permalink
feat: Add CreatedAt and UpdatedAt to Ruleset (google#3316)
Browse files Browse the repository at this point in the history
Fixes: google#3315.
  • Loading branch information
ivanmartos authored Oct 8, 2024
1 parent 139eec8 commit 13afa20
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
16 changes: 16 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions github/repos_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ type Ruleset struct {
Links *RulesetLinks `json:"_links,omitempty"`
Conditions *RulesetConditions `json:"conditions,omitempty"`
Rules []*RepositoryRule `json:"rules,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}

// rulesetNoOmitBypassActors represents a GitHub ruleset object. The struct does not omit bypassActors if the field is nil or an empty array is passed.
Expand Down
18 changes: 15 additions & 3 deletions github/repos_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,18 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) {
"name": "ruleset",
"source_type": "Repository",
"source": "o/repo",
"enforcement": "enabled"
"enforcement": "enabled",
"created_at": `+referenceTimeStr+`,
"updated_at": `+referenceTimeStr+`
},
{
"id": 314,
"name": "Another ruleset",
"source_type": "Repository",
"source": "o/repo",
"enforcement": "enabled"
"enforcement": "enabled",
"created_at": `+referenceTimeStr+`,
"updated_at": `+referenceTimeStr+`
}
]`)
})
Expand All @@ -514,13 +518,17 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) {
SourceType: String("Repository"),
Source: "o/repo",
Enforcement: "enabled",
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
},
{
ID: Int64(314),
Name: "Another ruleset",
SourceType: String("Repository"),
Source: "o/repo",
Enforcement: "enabled",
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
},
}
if !cmp.Equal(ruleSet, want) {
Expand Down Expand Up @@ -683,7 +691,9 @@ func TestRepositoriesService_GetRuleset(t *testing.T) {
"name": "ruleset",
"source_type": "Organization",
"source": "o",
"enforcement": "enabled"
"enforcement": "enabled",
"created_at": `+referenceTimeStr+`,
"updated_at": `+referenceTimeStr+`
}`)
})

Expand All @@ -699,6 +709,8 @@ func TestRepositoriesService_GetRuleset(t *testing.T) {
SourceType: String("Organization"),
Source: "o",
Enforcement: "enabled",
CreatedAt: &Timestamp{referenceTime},
UpdatedAt: &Timestamp{referenceTime},
}
if !cmp.Equal(ruleSet, want) {
t.Errorf("Repositories.GetRuleset returned %+v, want %+v", ruleSet, want)
Expand Down

0 comments on commit 13afa20

Please sign in to comment.