From 1a6dc0f493b752e746c1de94d7ba9b16475c9e27 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:13:55 -0400 Subject: [PATCH 01/34] chore: Replace time.Date with referenceTime Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_hosted_runners_test.go | 35 ++++--- github/actions_runner_groups_test.go | 11 +-- github/actions_runners_test.go | 23 ++--- github/actions_secrets_test.go | 45 +++++---- github/actions_variables_test.go | 45 +++++---- github/actions_workflow_jobs_test.go | 29 +++--- github/actions_workflow_runs_test.go | 37 ++++--- github/actions_workflows_test.go | 19 ++-- github/activity_notifications_test.go | 17 ++-- github/activity_star_test.go | 13 ++- github/admin_users_test.go | 10 +- github/apps_test.go | 15 ++- github/classroom_test.go | 29 +++--- github/code_quality_test.go | 5 +- github/code_scanning_test.go | 53 +++++----- github/codespaces_secrets_test.go | 19 ++-- github/codespaces_test.go | 17 ++-- github/copilot_test.go | 97 +++++++++--------- github/dependabot_secrets_test.go | 27 +++-- github/dependency_graph_snapshots_test.go | 7 +- github/dependency_graph_test.go | 6 +- .../enterprise_actions_hosted_runners_test.go | 43 ++++---- github/enterprise_actions_runners_test.go | 8 +- github/enterprise_licenses_test.go | 5 +- github/enterprise_manage_ghes_config_test.go | 21 ++-- ...enterprise_manage_ghes_maintenance_test.go | 5 +- .../enterprise_network_configurations_test.go | 21 ++-- github/enterprise_team_test.go | 9 +- github/gists_test.go | 31 +++--- github/git_commits_test.go | 33 +++---- github/github_test.go | 41 ++++---- github/issue_import_test.go | 26 +++-- github/issues_comments_test.go | 6 +- github/issues_test.go | 15 ++- github/orgs_credential_authorizations_test.go | 10 +- github/orgs_custom_repository_roles_test.go | 17 ++-- github/orgs_issue_types_test.go | 33 +++---- github/orgs_members_test.go | 15 ++- github/orgs_network_configurations_test.go | 25 +++-- github/orgs_organization_roles_test.go | 17 ++-- github/orgs_personal_access_tokens_test.go | 17 ++-- github/private_registries_test.go | 41 ++++---- github/projects_test.go | 13 ++- github/pulls_comments_test.go | 5 +- github/rate_limit_test.go | 99 +++++++++---------- github/repos_commits_test.go | 9 +- github/repos_community_health_test.go | 6 +- github/repos_stats_test.go | 13 ++- github/repos_test.go | 21 ++-- github/repos_traffic_test.go | 9 +- github/scim_test.go | 13 ++- github/secret_scanning_test.go | 54 ++++------ github/security_advisories_test.go | 45 +++++---- github/teams_discussion_comments_test.go | 9 +- github/teams_discussions_test.go | 17 ++-- github/timestamp_test.go | 6 +- 56 files changed, 607 insertions(+), 710 deletions(-) diff --git a/github/actions_hosted_runners_test.go b/github/actions_hosted_runners_test.go index 4a98f800c71..1afa8e0b533 100644 --- a/github/actions_hosted_runners_test.go +++ b/github/actions_hosted_runners_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -48,7 +47,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }, { "id": 7, @@ -69,7 +68,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) { "maximum_runners": 20, "public_ip_enabled": false, "public_ips": [], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` } ] }`) @@ -81,7 +80,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) { t.Errorf("Actions.ListHostedRunners returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} + lastActiveOn := referenceTimestamp want := &HostedRunners{ TotalCount: 2, @@ -186,7 +185,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -210,7 +209,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { t.Errorf("Actions.CreateHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} + lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -616,7 +615,7 @@ func TestActionsService_GetHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -626,7 +625,7 @@ func TestActionsService_GetHostedRunner(t *testing.T) { t.Errorf("Actions.GetHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} + lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -705,7 +704,7 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -722,7 +721,7 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { t.Errorf("Actions.UpdateHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} + lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -801,7 +800,7 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -811,7 +810,7 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) { t.Errorf("Actions.DeleteHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} + lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -1036,14 +1035,14 @@ func TestActionsService_ListHostedRunnerCustomImageVersions(t *testing.T) { "size_gb": 75, "state": "Ready", "state_details": "None", - "created_on": "2024-11-09T23:39:01Z" + "created_on": `+referenceTimeStr+` }, { "version": "1.0.0", "size_gb": 75, "state": "Ready", "state_details": "None", - "created_on": "2024-11-08T20:39:01Z" + "created_on": `+referenceTimeStr+` } ] }`) @@ -1063,14 +1062,14 @@ func TestActionsService_ListHostedRunnerCustomImageVersions(t *testing.T) { SizeGB: 75, State: "Ready", StateDetails: "None", - CreatedOn: Timestamp{time.Date(2024, 11, 9, 23, 39, 1, 0, time.UTC)}, + CreatedOn: referenceTimestamp, }, { Version: "1.0.0", SizeGB: 75, State: "Ready", StateDetails: "None", - CreatedOn: Timestamp{time.Date(2024, 11, 8, 20, 39, 1, 0, time.UTC)}, + CreatedOn: referenceTimestamp, }, }, } @@ -1105,7 +1104,7 @@ func TestActionsService_GetHostedRunnerCustomImageVersion(t *testing.T) { "size_gb": 75, "state": "Ready", "state_details": "None", - "created_on": "2024-11-08T20:39:01Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -1120,7 +1119,7 @@ func TestActionsService_GetHostedRunnerCustomImageVersion(t *testing.T) { SizeGB: 75, State: "Ready", StateDetails: "None", - CreatedOn: Timestamp{time.Date(2024, 11, 8, 20, 39, 1, 0, time.UTC)}, + CreatedOn: referenceTimestamp, } if !cmp.Equal(version, want) { diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index 21cedd6d759..51578b1ee20 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -449,7 +448,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }, { "id": 7, @@ -470,7 +469,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { "maximum_runners": 20, "public_ip_enabled": false, "public_ips": [], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` } ] }`) @@ -483,8 +482,6 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { t.Errorf("Actions.ListRunnerGroupHostedRunners returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} - want := &HostedRunners{ TotalCount: 2, Runners: []*HostedRunner{ @@ -513,7 +510,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, }, { ID: Ptr(int64(7)), @@ -534,7 +531,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) { MaximumRunners: Ptr(int64(20)), PublicIPEnabled: Ptr(false), PublicIPs: []*HostedRunnerPublicIP{}, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, }, }, } diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index ec487410038..1c8e085f58d 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -137,7 +136,7 @@ func TestActionsService_CreateRegistrationToken(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runners/registration-token", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprint(w, `{"token":"LLBF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":"2020-01-22T12:13:35.123Z"}`) + fmt.Fprint(w, `{"token":"LLBF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -147,9 +146,8 @@ func TestActionsService_CreateRegistrationToken(t *testing.T) { } want := &RegistrationToken{ - Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), - ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35, - 123000000, time.UTC)}, + Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + ExpiresAt: &referenceTimestamp, } if !cmp.Equal(token, want) { t.Errorf("Actions.CreateRegistrationToken returned %+v, want %+v", token, want) @@ -261,7 +259,7 @@ func TestActionsService_CreateRemoveToken(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runners/remove-token", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprint(w, `{"token":"AABF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":"2020-01-29T12:13:35.123Z"}`) + fmt.Fprint(w, `{"token":"AABF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -270,7 +268,7 @@ func TestActionsService_CreateRemoveToken(t *testing.T) { t.Errorf("Actions.CreateRemoveToken returned error: %v", err) } - want := &RemoveToken{Token: Ptr("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 29, 12, 13, 35, 123000000, time.UTC)}} + want := &RemoveToken{Token: Ptr("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp} if !cmp.Equal(token, want) { t.Errorf("Actions.CreateRemoveToken returned %+v, want %+v", token, want) } @@ -362,7 +360,7 @@ func TestActionsService_CreateOrganizationRegistrationToken(t *testing.T) { mux.HandleFunc("/orgs/o/actions/runners/registration-token", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprint(w, `{"token":"LLBF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":"2020-01-22T12:13:35.123Z"}`) + fmt.Fprint(w, `{"token":"LLBF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -372,9 +370,8 @@ func TestActionsService_CreateOrganizationRegistrationToken(t *testing.T) { } want := &RegistrationToken{ - Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), - ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35, - 123000000, time.UTC)}, + Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + ExpiresAt: &referenceTimestamp, } if !cmp.Equal(token, want) { t.Errorf("Actions.CreateOrganizationRegistrationToken returned %+v, want %+v", token, want) @@ -486,7 +483,7 @@ func TestActionsService_CreateOrganizationRemoveToken(t *testing.T) { mux.HandleFunc("/orgs/o/actions/runners/remove-token", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprint(w, `{"token":"AABF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":"2020-01-29T12:13:35.123Z"}`) + fmt.Fprint(w, `{"token":"AABF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -495,7 +492,7 @@ func TestActionsService_CreateOrganizationRemoveToken(t *testing.T) { t.Errorf("Actions.CreateOrganizationRemoveToken returned error: %v", err) } - want := &RemoveToken{Token: Ptr("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &Timestamp{time.Date(2020, time.January, 29, 12, 13, 35, 123000000, time.UTC)}} + want := &RemoveToken{Token: Ptr("AABF3JGZDX3P5PMEXLND6TS6FCWO6"), ExpiresAt: &referenceTimestamp} if !cmp.Equal(token, want) { t.Errorf("Actions.CreateOrganizationRemoveToken returned %+v, want %+v", token, want) } diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index 25411902e4c..bb7966c283d 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -169,7 +168,7 @@ func TestActionsService_ListRepoSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -182,8 +181,8 @@ func TestActionsService_ListRepoSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, }, } if !cmp.Equal(secrets, want) { @@ -212,7 +211,7 @@ func TestActionsService_ListRepoOrgSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/organization-secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -225,8 +224,8 @@ func TestActionsService_ListRepoOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, }, } if !cmp.Equal(secrets, want) { @@ -254,7 +253,7 @@ func TestActionsService_GetRepoSecret(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -265,8 +264,8 @@ func TestActionsService_GetRepoSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: referenceTimestamp, + UpdatedAt: referenceTimestamp, } if !cmp.Equal(secret, want) { t.Errorf("Actions.GetRepoSecret returned %+v, want %+v", secret, want) @@ -396,7 +395,7 @@ func TestActionsService_ListOrgSecrets(t *testing.T) { mux.HandleFunc("/orgs/o/actions/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"all"},{"name":"GH_TOKEN","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}]}`) + fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"all"},{"name":"GH_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -409,9 +408,9 @@ func TestActionsService_ListOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 3, Secrets: []*Secret{ - {Name: "GIST_ID", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "private"}, - {Name: "DEPLOY_TOKEN", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "all"}, - {Name: "GH_TOKEN", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}, + {Name: "GIST_ID", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "private"}, + {Name: "DEPLOY_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "all"}, + {Name: "GH_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}, }, } if !cmp.Equal(secrets, want) { @@ -439,7 +438,7 @@ func TestActionsService_GetOrgSecret(t *testing.T) { mux.HandleFunc("/orgs/o/actions/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z","visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}`) }) ctx := t.Context() @@ -450,8 +449,8 @@ func TestActionsService_GetOrgSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: referenceTimestamp, + UpdatedAt: referenceTimestamp, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories", } @@ -756,7 +755,7 @@ func TestActionsService_ListEnvSecrets(t *testing.T) { mux.HandleFunc("/repositories/1/environments/e/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -769,8 +768,8 @@ func TestActionsService_ListEnvSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, }, } if !cmp.Equal(secrets, want) { @@ -798,7 +797,7 @@ func TestActionsService_GetEnvSecret(t *testing.T) { mux.HandleFunc("/repositories/1/environments/e/secrets/secret", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"secret","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"secret","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -809,8 +808,8 @@ func TestActionsService_GetEnvSecret(t *testing.T) { want := &Secret{ Name: "secret", - CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: referenceTimestamp, + UpdatedAt: referenceTimestamp, } if !cmp.Equal(secret, want) { t.Errorf("Actions.GetEnvSecret returned %+v, want %+v", secret, want) diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index 07a51bccfef..238831d702d 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -21,7 +20,7 @@ func TestActionsService_ListRepoVariables(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","value":"BB","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -34,8 +33,8 @@ func TestActionsService_ListRepoVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } if !cmp.Equal(variables, want) { @@ -64,7 +63,7 @@ func TestActionsService_ListRepoOrgVariables(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/organization-variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","value":"BB","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -77,8 +76,8 @@ func TestActionsService_ListRepoOrgVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } if !cmp.Equal(variables, want) { @@ -106,7 +105,7 @@ func TestActionsService_GetRepoVariable(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -118,8 +117,8 @@ func TestActionsService_GetRepoVariable(t *testing.T) { want := &ActionsVariable{ Name: "NAME", Value: "VALUE", - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetRepoVariable returned %+v, want %+v", variable, want) @@ -242,7 +241,7 @@ func TestActionsService_ListOrgVariables(t *testing.T) { mux.HandleFunc("/orgs/o/actions/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"variables":[{"name":"A","value":"AA","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"private"},{"name":"B","value":"BB","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"all"},{"name":"C","value":"CC","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}]}`) + fmt.Fprint(w, `{"total_count":3,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"private"},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"all"},{"name":"C","value":"CC","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -255,9 +254,9 @@ func TestActionsService_ListOrgVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 3, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: Ptr("private")}, - {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: Ptr("all")}, - {Name: "C", Value: "CC", CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories")}, + {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, Visibility: Ptr("private")}, + {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, Visibility: Ptr("all")}, + {Name: "C", Value: "CC", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories")}, }, } if !cmp.Equal(variables, want) { @@ -285,7 +284,7 @@ func TestActionsService_GetOrgVariable(t *testing.T) { mux.HandleFunc("/orgs/o/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z","visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}`) + fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}`) }) ctx := t.Context() @@ -297,8 +296,8 @@ func TestActionsService_GetOrgVariable(t *testing.T) { want := &ActionsVariable{ Name: "NAME", Value: "VALUE", - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"), } @@ -569,7 +568,7 @@ func TestActionsService_ListEnvVariables(t *testing.T) { mux.HandleFunc("/repos/usr/1/environments/e/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","value":"BB","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -582,8 +581,8 @@ func TestActionsService_ListEnvVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } if !cmp.Equal(variables, want) { @@ -611,7 +610,7 @@ func TestActionsService_GetEnvVariable(t *testing.T) { mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"variable","value":"VAR","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"variable","value":"VAR","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -623,8 +622,8 @@ func TestActionsService_GetEnvVariable(t *testing.T) { want := &ActionsVariable{ Name: "variable", Value: "VAR", - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetEnvVariable returned %+v, want %+v", variable, want) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 83c969310b1..3fd07256993 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -12,7 +12,6 @@ import ( "net/url" "strings" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -24,7 +23,7 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`},{"id":399444497,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`}]}`) }) opts := &ListWorkflowJobsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -37,8 +36,8 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { want := &Jobs{ TotalCount: Ptr(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, }, } if !cmp.Equal(jobs, want) { @@ -67,7 +66,7 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"filter": "all", "per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`},{"id":399444497,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`}]}`) }) opts := &ListWorkflowJobsOptions{Filter: "all", ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -80,8 +79,8 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) { want := &Jobs{ TotalCount: Ptr(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, }, } if !cmp.Equal(jobs, want) { @@ -96,7 +95,7 @@ func TestActionsService_ListWorkflowJobsAttempt(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/attempts/1/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z","run_attempt":2},{"id":399444497,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z","run_attempt":2}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`,"run_attempt":2},{"id":399444497,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`,"run_attempt":2}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} ctx := t.Context() @@ -111,15 +110,15 @@ func TestActionsService_ListWorkflowJobsAttempt(t *testing.T) { { ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), - StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + StartedAt: &referenceTimestamp, + CompletedAt: &referenceTimestamp, RunAttempt: Ptr(int64(2)), }, { ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), - StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + StartedAt: &referenceTimestamp, + CompletedAt: &referenceTimestamp, RunAttempt: Ptr(int64(2)), }, }, @@ -149,7 +148,7 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/jobs/399444496", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":399444496,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"id":399444496,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -160,8 +159,8 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { want := &WorkflowJob{ ID: Ptr(int64(399444496)), - StartedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - CompletedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + StartedAt: &referenceTimestamp, + CompletedAt: &referenceTimestamp, } if !cmp.Equal(job, want) { t.Errorf("Actions.GetWorkflowJobByID returned %+v, want %+v", job, want) diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index d60bfe32a24..3cf36b73931 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -12,7 +12,6 @@ import ( "net/url" "strings" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -24,7 +23,7 @@ func TestActionsService_ListWorkflowRunsByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/29679449/runs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"id":399444497,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -37,8 +36,8 @@ func TestActionsService_ListWorkflowRunsByID(t *testing.T) { want := &WorkflowRuns{ TotalCount: Ptr(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } if !cmp.Equal(runs, want) { @@ -67,7 +66,7 @@ func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/29679449/runs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"id":399444497,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -80,8 +79,8 @@ func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { want := &WorkflowRuns{ TotalCount: Ptr(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } if !cmp.Equal(runs, want) { @@ -109,7 +108,7 @@ func TestActionsService_GetWorkflowRunByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":399444496,"run_number":296,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"id":399444496,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -121,8 +120,8 @@ func TestActionsService_GetWorkflowRunByID(t *testing.T) { want := &WorkflowRun{ ID: Ptr(int64(399444496)), RunNumber: Ptr(296), - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(runs, want) { @@ -151,7 +150,7 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/attempts/3", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"exclude_pull_requests": "true"}) - fmt.Fprint(w, `{"id":399444496,"run_number":296,"run_attempt":3,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"id":399444496,"run_number":296,"run_attempt":3,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) opts := &WorkflowRunAttemptOptions{ExcludePullRequests: Ptr(true)} @@ -165,8 +164,8 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { ID: Ptr(int64(399444496)), RunNumber: Ptr(296), RunAttempt: Ptr(3), - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(runs, want) { @@ -703,8 +702,8 @@ func TestActionsService_ListRepositoryWorkflowRuns(t *testing.T) { testFormValues(t, r, values{"per_page": "2", "page": "2"}) fmt.Fprint(w, `{"total_count":2, "workflow_runs":[ - {"id":298499444,"run_number":301,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}, - {"id":298499445,"run_number":302,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}]}`) + {"id":298499444,"run_number":301,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}, + {"id":298499445,"run_number":302,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -717,8 +716,8 @@ func TestActionsService_ListRepositoryWorkflowRuns(t *testing.T) { expected := &WorkflowRuns{ TotalCount: Ptr(2), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(298499444)), RunNumber: Ptr(301), CreatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}}, - {ID: Ptr(int64(298499445)), RunNumber: Ptr(302), CreatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.April, 11, 11, 14, 54, 0, time.UTC)}}, + {ID: Ptr(int64(298499444)), RunNumber: Ptr(301), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(298499445)), RunNumber: Ptr(302), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } @@ -999,7 +998,7 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { HTMLURL: Ptr("hu"), }, WaitTimer: Ptr(int64(0)), - WaitTimerStartedAt: &Timestamp{referenceTime}, + WaitTimerStartedAt: &referenceTimestamp, CurrentUserCanApprove: Ptr(false), Reviewers: []*RequiredReviewer{}, }, @@ -1012,7 +1011,7 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { HTMLURL: Ptr("hu"), }, WaitTimer: Ptr(int64(13)), - WaitTimerStartedAt: &Timestamp{referenceTime}, + WaitTimerStartedAt: &referenceTimestamp, CurrentUserCanApprove: Ptr(true), Reviewers: []*RequiredReviewer{ { diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index c69c78f7274..b8496412230 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -21,7 +20,7 @@ func TestActionsService_ListWorkflows(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":72845,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"id":72845,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -34,8 +33,8 @@ func TestActionsService_ListWorkflows(t *testing.T) { want := &Workflows{ TotalCount: Ptr(4), Workflows: []*Workflow{ - {ID: Ptr(int64(72844)), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {ID: Ptr(int64(72845)), CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {ID: Ptr(int64(72844)), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(72845)), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, }, } if !cmp.Equal(workflows, want) { @@ -63,7 +62,7 @@ func TestActionsService_GetWorkflowByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/72844", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"id":72844,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -74,8 +73,8 @@ func TestActionsService_GetWorkflowByID(t *testing.T) { want := &Workflow{ ID: Ptr(int64(72844)), - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(workflow, want) { t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want) @@ -102,7 +101,7 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/main.yml", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"id":72844,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -113,8 +112,8 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) { want := &Workflow{ ID: Ptr(int64(72844)), - CreatedAt: &Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(workflow, want) { t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index af7c6c38b1d..fa64d1cad80 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -23,8 +22,8 @@ func TestActivityService_ListNotification(t *testing.T) { testFormValues(t, r, values{ "all": "true", "participating": "true", - "since": "2006-01-02T15:04:05Z", - "before": "2007-03-04T15:04:05Z", + "since": referenceTimeRaw, + "before": referenceTimeRaw, }) fmt.Fprint(w, `[{"id":"1", "subject":{"title":"t"}}]`) @@ -33,8 +32,8 @@ func TestActivityService_ListNotification(t *testing.T) { opt := &NotificationListOptions{ All: true, Participating: true, - Since: time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC), - Before: time.Date(2007, time.March, 4, 15, 4, 5, 0, time.UTC), + Since: referenceTime, + Before: referenceTime, } ctx := t.Context() notifications, _, err := client.Activity.ListNotifications(ctx, opt) @@ -96,7 +95,7 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)} + input := referenceTimestamp mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -125,7 +124,7 @@ func TestActivityService_MarkNotificationsRead_EmptyLastReadAt(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := Timestamp{} + input := referenceTimestamp mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -149,7 +148,7 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)} + input := referenceTimestamp mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -182,7 +181,7 @@ func TestActivityService_MarkRepositoryNotificationsRead_EmptyLastReadAt(t *test t.Parallel() client, mux, _ := setup(t) - input := Timestamp{} + input := referenceTimestamp mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 7ebf1b1c8d6..6286a166772 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -10,7 +10,6 @@ import ( "net/http" "strings" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -26,7 +25,7 @@ func TestActivityService_ListStargazers(t *testing.T) { "page": "2", }) - fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","user":{"id":1}}]`) + fmt.Fprint(w, `[{"starred_at":`+referenceTimeStr+`,"user":{"id":1}}]`) }) ctx := t.Context() @@ -35,7 +34,7 @@ func TestActivityService_ListStargazers(t *testing.T) { t.Errorf("Activity.ListStargazers returned error: %v", err) } - want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Ptr(int64(1))}}} + want := []*Stargazer{{StarredAt: &referenceTimestamp, User: &User{ID: Ptr(int64(1))}}} if !cmp.Equal(stargazers, want) { t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want) } @@ -62,7 +61,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { mux.HandleFunc("/user/starred", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testHeader(t, r, "Accept", strings.Join([]string{mediaTypeStarring, mediaTypeTopicsPreview}, ", ")) - fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","repo":{"id":1}}]`) + fmt.Fprint(w, `[{"starred_at":`+referenceTimeStr+`,"repo":{"id":1}}]`) }) ctx := t.Context() @@ -71,7 +70,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { t.Errorf("Activity.ListStarred returned error: %v", err) } - want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Ptr(int64(1))}}} + want := []*StarredRepository{{StarredAt: &referenceTimestamp, Repository: &Repository{ID: Ptr(int64(1))}}} if !cmp.Equal(repos, want) { t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want) } @@ -103,7 +102,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { "direction": "asc", "page": "2", }) - fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","repo":{"id":2}}]`) + fmt.Fprint(w, `[{"starred_at":`+referenceTimeStr+`,"repo":{"id":2}}]`) }) opt := &ActivityListStarredOptions{"created", "asc", ListOptions{Page: 2}} @@ -113,7 +112,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { t.Errorf("Activity.ListStarred returned error: %v", err) } - want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Ptr(int64(2))}}} + want := []*StarredRepository{{StarredAt: &referenceTimestamp, Repository: &Repository{ID: Ptr(int64(2))}}} if !cmp.Equal(repos, want) { t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want) } diff --git a/github/admin_users_test.go b/github/admin_users_test.go index 1cfd7f40f52..d39414a3878 100644 --- a/github/admin_users_test.go +++ b/github/admin_users_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -93,8 +92,8 @@ func TestUserImpersonation_Create(t *testing.T) { "token_last_eight": "1234", "note": null, "note_url": null, - "created_at": "2018-01-01T00:00:00Z", - "updated_at": "2018-01-01T00:00:00Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "scopes": [ "repo" ], @@ -107,7 +106,6 @@ func TestUserImpersonation_Create(t *testing.T) { t.Errorf("Admin.CreateUserImpersonation returned error: %v", err) } - date := Timestamp{Time: time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)} want := &UserAuthorization{ ID: Ptr(int64(1234)), URL: Ptr("https://example.com/authorizations"), @@ -121,8 +119,8 @@ func TestUserImpersonation_Create(t *testing.T) { TokenLastEight: Ptr("1234"), Note: nil, NoteURL: nil, - CreatedAt: &date, - UpdatedAt: &date, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Scopes: []string{"repo"}, Fingerprint: nil, } diff --git a/github/apps_test.go b/github/apps_test.go index 55c9b2bd00c..93b34482817 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -84,7 +83,7 @@ func TestAppsService_ListInstallationRequests(t *testing.T) { "id": 1, "account": { "id": 2 }, "requester": { "id": 3 }, - "created_at": "2018-01-01T00:00:00Z" + "created_at": `+referenceTimeStr+` }]`, ) }) @@ -96,12 +95,11 @@ func TestAppsService_ListInstallationRequests(t *testing.T) { t.Errorf("Apps.ListInstallationRequests returned error: %v", err) } - date := Timestamp{Time: time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)} want := []*InstallationRequest{{ ID: Ptr(int64(1)), Account: &User{ID: Ptr(int64(2))}, Requester: &User{ID: Ptr(int64(3))}, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, }} if !cmp.Equal(installationRequests, want) { t.Errorf("Apps.ListInstallationRequests returned %+v, want %+v", installationRequests, want) @@ -176,8 +174,8 @@ func TestAppsService_ListInstallations(t *testing.T) { ], "single_file_name": "config.yml", "repository_selection": "selected", - "created_at": "2018-01-01T00:00:00Z", - "updated_at": "2018-01-01T00:00:00Z"}]`, + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`}]`, ) }) @@ -188,7 +186,6 @@ func TestAppsService_ListInstallations(t *testing.T) { t.Errorf("Apps.ListInstallations returned error: %v", err) } - date := Timestamp{Time: time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)} want := []*Installation{{ ID: Ptr(int64(1)), AppID: Ptr(int64(1)), @@ -235,8 +232,8 @@ func TestAppsService_ListInstallations(t *testing.T) { Workflows: Ptr("write"), }, Events: []string{"push", "pull_request"}, - CreatedAt: &date, - UpdatedAt: &date, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, }} if !cmp.Equal(installations, want) { t.Errorf("Apps.ListInstallations returned %+v, want %+v", installations, want) diff --git a/github/classroom_test.go b/github/classroom_test.go index cd96676f127..9cc64b98946 100644 --- a/github/classroom_test.go +++ b/github/classroom_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -37,7 +36,7 @@ func TestClassroomService_GetAssignment(t *testing.T) { "submitted": 40, "passing": 10, "language": "ruby", - "deadline": "2011-01-26T19:06:43Z", + "deadline": `+referenceTimeStr+`, "starter_code_repository": { "id": 1296269, "full_name": "octocat/Hello-World", @@ -78,7 +77,7 @@ func TestClassroomService_GetAssignment(t *testing.T) { Submitted: Ptr(40), Passing: Ptr(10), Language: Ptr("ruby"), - Deadline: func() *Timestamp { t, _ := time.Parse(time.RFC3339, "2011-01-26T19:06:43Z"); return &Timestamp{t} }(), + Deadline: &referenceTimestamp, StarterCodeRepository: &Repository{ ID: Ptr(int64(1296269)), FullName: Ptr("octocat/Hello-World"), @@ -260,7 +259,7 @@ func TestClassroomService_ListClassroomAssignments(t *testing.T) { "submitted": 40, "passing": 10, "language": "ruby", - "deadline": "2011-01-26T19:06:43Z", + "deadline": `+referenceTimeStr+`, "classroom": { "id": 1296269, "name": "Programming Elixir", @@ -285,7 +284,7 @@ func TestClassroomService_ListClassroomAssignments(t *testing.T) { "submitted": 25, "passing": 20, "language": "python", - "deadline": "2020-01-11T11:59:22Z", + "deadline": `+referenceTimeStr+`, "classroom": { "id": 1296269, "name": "Programming Elixir", @@ -321,7 +320,7 @@ func TestClassroomService_ListClassroomAssignments(t *testing.T) { Submitted: Ptr(40), Passing: Ptr(10), Language: Ptr("ruby"), - Deadline: func() *Timestamp { t, _ := time.Parse(time.RFC3339, "2011-01-26T19:06:43Z"); return &Timestamp{t} }(), + Deadline: &referenceTimestamp, Classroom: &Classroom{ ID: Ptr(int64(1296269)), Name: Ptr("Programming Elixir"), @@ -346,7 +345,7 @@ func TestClassroomService_ListClassroomAssignments(t *testing.T) { Submitted: Ptr(25), Passing: Ptr(20), Language: Ptr("python"), - Deadline: func() *Timestamp { t, _ := time.Parse(time.RFC3339, "2020-01-11T11:59:22Z"); return &Timestamp{t} }(), + Deadline: &referenceTimestamp, Classroom: &Classroom{ ID: Ptr(int64(1296269)), Name: Ptr("Programming Elixir"), @@ -422,7 +421,7 @@ func TestClassroomService_ListAcceptedAssignments(t *testing.T) { "submitted": 40, "passing": 10, "language": "ruby", - "deadline": "2011-01-26T19:06:43Z", + "deadline": `+referenceTimeStr+`, "classroom": { "id": 1296269, "name": "Programming Elixir", @@ -470,7 +469,7 @@ func TestClassroomService_ListAcceptedAssignments(t *testing.T) { "submitted": 40, "passing": 10, "language": "ruby", - "deadline": "2011-01-26T19:06:43Z", + "deadline": `+referenceTimeStr+`, "classroom": { "id": 1296269, "name": "Programming Elixir", @@ -529,7 +528,7 @@ func TestClassroomService_ListAcceptedAssignments(t *testing.T) { Submitted: Ptr(40), Passing: Ptr(10), Language: Ptr("ruby"), - Deadline: &Timestamp{time.Date(2011, 1, 26, 19, 6, 43, 0, time.UTC)}, + Deadline: &referenceTimestamp, Classroom: &Classroom{ ID: Ptr(int64(1296269)), Name: Ptr("Programming Elixir"), @@ -577,7 +576,7 @@ func TestClassroomService_ListAcceptedAssignments(t *testing.T) { Submitted: Ptr(40), Passing: Ptr(10), Language: Ptr("ruby"), - Deadline: &Timestamp{time.Date(2011, 1, 26, 19, 6, 43, 0, time.UTC)}, + Deadline: &referenceTimestamp, Classroom: &Classroom{ ID: Ptr(int64(1296269)), Name: Ptr("Programming Elixir"), @@ -622,7 +621,7 @@ func TestClassroomService_GetAssignmentGrades(t *testing.T) { "roster_identifier": "student123", "student_repository_name": "octocat/intro-to-binaries", "student_repository_url": "https://github.com/octocat/intro-to-binaries", - "submission_timestamp": "2011-01-26T19:06:43Z", + "submission_timestamp": `+referenceTimeStr+`, "points_awarded": 10, "points_available": 10, "group_name": "Team Alpha" @@ -635,7 +634,7 @@ func TestClassroomService_GetAssignmentGrades(t *testing.T) { "roster_identifier": "student456", "student_repository_name": "monalisa/intro-to-binaries", "student_repository_url": "https://github.com/monalisa/intro-to-binaries", - "submission_timestamp": "2011-01-27T10:30:15Z", + "submission_timestamp": `+referenceTimeStr+`, "points_awarded": 8, "points_available": 10, "group_name": "Team Beta" @@ -658,7 +657,7 @@ func TestClassroomService_GetAssignmentGrades(t *testing.T) { RosterIdentifier: Ptr("student123"), StudentRepositoryName: Ptr("octocat/intro-to-binaries"), StudentRepositoryURL: Ptr("https://github.com/octocat/intro-to-binaries"), - SubmissionTimestamp: &Timestamp{time.Date(2011, 1, 26, 19, 6, 43, 0, time.UTC)}, + SubmissionTimestamp: &referenceTimestamp, PointsAwarded: Ptr(10), PointsAvailable: Ptr(10), GroupName: Ptr("Team Alpha"), @@ -671,7 +670,7 @@ func TestClassroomService_GetAssignmentGrades(t *testing.T) { RosterIdentifier: Ptr("student456"), StudentRepositoryName: Ptr("monalisa/intro-to-binaries"), StudentRepositoryURL: Ptr("https://github.com/monalisa/intro-to-binaries"), - SubmissionTimestamp: &Timestamp{time.Date(2011, 1, 27, 10, 30, 15, 0, time.UTC)}, + SubmissionTimestamp: &referenceTimestamp, PointsAwarded: Ptr(8), PointsAvailable: Ptr(10), GroupName: Ptr("Team Beta"), diff --git a/github/code_quality_test.go b/github/code_quality_test.go index e7df70b3ef5..b6f7e9c6562 100644 --- a/github/code_quality_test.go +++ b/github/code_quality_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -25,7 +24,7 @@ func TestCodeQualityService_GetSetup(t *testing.T) { "languages": ["javascript-typescript", "python"], "runner_type": "standard", "runner_label": null, - "updated_at": "2026-01-01T00:00:00Z", + "updated_at": `+referenceTimeStr+`, "schedule": "weekly" }`) }) @@ -40,7 +39,7 @@ func TestCodeQualityService_GetSetup(t *testing.T) { State: Ptr("configured"), Languages: []string{"javascript-typescript", "python"}, RunnerType: Ptr("standard"), - UpdatedAt: &Timestamp{time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC)}, + UpdatedAt: &referenceTimestamp, Schedule: Ptr("weekly"), } if diff := cmp.Diff(want, cfg); diff != "" { diff --git a/github/code_scanning_test.go b/github/code_scanning_test.go index d3ec8670f6b..3f6c6a1bad2 100644 --- a/github/code_scanning_test.go +++ b/github/code_scanning_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -63,7 +62,7 @@ func TestCodeScanningService_UploadSarif(t *testing.T) { URL: Ptr("https://example.com/testurl"), } - sarifAnalysis := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)}, ToolName: Ptr("codeql-cli")} + sarifAnalysis := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &referenceTimestamp, ToolName: Ptr("codeql-cli")} mux.HandleFunc("/repos/o/r/code-scanning/sarifs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") @@ -182,7 +181,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { "test" ] }, - "created_at":"2020-05-06T12:00:00Z", + "created_at":`+referenceTimeStr+`, "state":"open", "closed_by":null, "closed_at":null, @@ -224,7 +223,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { "test" ] }, - "created_at":"2020-05-06T12:00:00Z", + "created_at":`+referenceTimeStr+`, "state":"open", "closed_by":null, "closed_at":null, @@ -240,7 +239,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(2020, time.May, 6, 12, 0, 0, 0, time.UTC)} + date := referenceTimestamp want := []*Alert{ { Repository: &Repository{ @@ -386,7 +385,7 @@ func TestCodeScanningService_ListAlertsForOrgLisCursorOptions(t *testing.T) { "test" ] }, - "created_at":"2020-05-06T12:00:00Z", + "created_at":`+referenceTimeStr+`, "state":"open", "closed_by":null, "closed_at":null, @@ -402,7 +401,7 @@ func TestCodeScanningService_ListAlertsForOrgLisCursorOptions(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(2020, time.May, 6, 12, 0, 0, 0, time.UTC)} + date := referenceTimestamp want := []*Alert{ { Repository: &Repository{ @@ -507,7 +506,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { "test" ] }, - "created_at":"2020-05-06T12:00:00Z", + "created_at":`+referenceTimeStr+`, "state":"open", "closed_by":null, "closed_at":null, @@ -549,7 +548,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { "test" ] }, - "created_at":"2020-05-06T12:00:00Z", + "created_at":`+referenceTimeStr+`, "state":"open", "closed_by":null, "closed_at":null, @@ -565,7 +564,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForRepo returned error: %v", err) } - date := Timestamp{time.Date(2020, time.May, 6, 12, 0, 0, 0, time.UTC)} + date := referenceTimestamp want := []*Alert{ { RuleID: Ptr("js/trivial-conditional"), @@ -699,7 +698,7 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { "test" ] }, - "created_at":"2019-01-02T15:04:05Z", + "created_at":`+referenceTimeStr+`, "state":"dismissed", "dismissed_reason": "false positive", "dismissed_comment": "This alert is not actually correct as sanitizer is used", @@ -719,7 +718,7 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { t.Errorf("CodeScanning.UpdateAlert returned error: %v", err) } - date := Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)} + date := referenceTimestamp want := &Alert{ RuleID: Ptr("js/useless-expression"), RuleSeverity: Ptr("warning"), @@ -897,7 +896,7 @@ func TestCodeScanningService_GetAlert(t *testing.T) { "test" ] }, - "created_at":"2019-01-02T15:04:05Z", + "created_at":`+referenceTimeStr+`, "state":"open", "closed_by":null, "closed_at":null, @@ -912,7 +911,7 @@ func TestCodeScanningService_GetAlert(t *testing.T) { t.Errorf("CodeScanning.GetAlert returned error: %v", err) } - date := Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)} + date := referenceTimestamp want := &Alert{ RuleID: Ptr("js/useless-expression"), RuleSeverity: Ptr("warning"), @@ -983,7 +982,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { "environment": "{\"language\":\"python\"}", "error": "", "category": ".github/workflows/codeql-analysis.yml:analyze/language:python", - "created_at": "2020-08-27T15:05:21Z", + "created_at": `+referenceTimeStr+`, "results_count": 17, "rules_count": 49, "id": 201, @@ -1004,7 +1003,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { "environment": "{}", "error": "", "category": ".github/workflows/shiftleft.yml:build/", - "created_at": "2020-08-27T15:05:21Z", + "created_at": `+referenceTimeStr+`, "results_count": 17, "rules_count": 32, "id": 200, @@ -1028,7 +1027,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { t.Errorf("CodeScanning.ListAnalysesForRepo returned error: %v", err) } - date := &Timestamp{time.Date(2020, time.August, 27, 15, 5, 21, 0, time.UTC)} + date := &referenceTimestamp want := []*ScanningAnalysis{ { ID: Ptr(int64(201)), @@ -1105,7 +1104,7 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { "environment": "{\"language\":\"javascript\"}", "error": "", "category": ".github/workflows/codeql-analysis.yml:analyze/language:javascript", - "created_at": "2021-01-13T11:55:49Z", + "created_at": `+referenceTimeStr+`, "results_count": 3, "rules_count": 67, "id": 3602840, @@ -1127,7 +1126,7 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { t.Errorf("CodeScanning.GetAnalysis returned error: %v", err) } - date := &Timestamp{time.Date(2021, time.January, 13, 11, 55, 49, 0, time.UTC)} + date := &referenceTimestamp want := &ScanningAnalysis{ ID: Ptr(int64(3602840)), Ref: Ptr("refs/heads/main"), @@ -1242,8 +1241,8 @@ func TestCodeScanningService_ListCodeQLDatabases(t *testing.T) { }, "content_type": "r", "size": 1024, - "created_at": "2021-01-13T11:55:49Z", - "updated_at": "2021-01-13T11:55:49Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "url": "s" } ]`) @@ -1255,7 +1254,7 @@ func TestCodeScanningService_ListCodeQLDatabases(t *testing.T) { t.Errorf("CodeScanning.ListCodeQLDatabases returned error: %v", err) } - date := &Timestamp{time.Date(2021, time.January, 13, 11, 55, 49, 0, time.UTC)} + date := &referenceTimestamp want := []*CodeQLDatabase{ { ID: Ptr(int64(1)), @@ -1340,8 +1339,8 @@ func TestCodeScanningService_GetCodeQLDatabase(t *testing.T) { }, "content_type": "r", "size": 1024, - "created_at": "2021-01-13T11:55:49Z", - "updated_at": "2021-01-13T11:55:49Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "url": "s" }`) }) @@ -1352,7 +1351,7 @@ func TestCodeScanningService_GetCodeQLDatabase(t *testing.T) { t.Errorf("CodeScanning.GetCodeQLDatabase returned error: %v", err) } - date := &Timestamp{time.Date(2021, time.January, 13, 11, 55, 49, 0, time.UTC)} + date := &referenceTimestamp want := &CodeQLDatabase{ ID: Ptr(int64(1)), Name: Ptr("name"), @@ -1417,7 +1416,7 @@ func TestCodeScanningService_GetDefaultSetupConfiguration(t *testing.T) { "typescript" ], "query_suite": "default", - "updated_at": "2006-01-02T15:04:05Z" + "updated_at": `+referenceTimeStr+` }`) if err != nil { t.Fatal(err) @@ -1430,7 +1429,7 @@ func TestCodeScanningService_GetDefaultSetupConfiguration(t *testing.T) { t.Errorf("CodeScanning.GetDefaultSetupConfiguration returned error: %v", err) } - date := &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)} + date := &referenceTimestamp want := &DefaultSetupConfiguration{ State: Ptr("configured"), Languages: []string{"javascript", "javascript-typescript", "typescript"}, diff --git a/github/codespaces_secrets_test.go b/github/codespaces_secrets_test.go index a74dc77710a..3a5210e552b 100644 --- a/github/codespaces_secrets_test.go +++ b/github/codespaces_secrets_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -32,7 +31,7 @@ func TestCodespacesService_ListSecrets(t *testing.T) { mux.HandleFunc("/user/codespaces/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) }, call: func(ctx context.Context, client *Client) (*Secrets, *Response, error) { @@ -46,7 +45,7 @@ func TestCodespacesService_ListSecrets(t *testing.T) { mux.HandleFunc("/orgs/o/codespaces/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) }, call: func(ctx context.Context, client *Client) (*Secrets, *Response, error) { @@ -63,7 +62,7 @@ func TestCodespacesService_ListSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/codespaces/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) }, call: func(ctx context.Context, client *Client) (*Secrets, *Response, error) { @@ -92,8 +91,8 @@ func TestCodespacesService_ListSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, }, } if !cmp.Equal(secrets, want) { @@ -133,7 +132,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/user/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) }, call: func(ctx context.Context, client *Client) (*Secret, *Response, error) { @@ -146,7 +145,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/orgs/o/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) }, call: func(ctx context.Context, client *Client) (*Secret, *Response, error) { @@ -162,7 +161,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/repos/o/r/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) }, call: func(ctx context.Context, client *Client) (*Secret, *Response, error) { @@ -188,7 +187,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { t.Errorf("Codespaces.%v returned error: %v", tt.methodName, err) } - want := &Secret{Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}} + want := &Secret{Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp} if !cmp.Equal(secret, want) { t.Errorf("Codespaces.%v returned %+v, want %+v", tt.methodName, secret, want) } diff --git a/github/codespaces_test.go b/github/codespaces_test.go index 4c6494d0190..664d03ffad2 100644 --- a/github/codespaces_test.go +++ b/github/codespaces_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -24,7 +23,7 @@ func TestCodespacesService_ListInRepo(t *testing.T) { "page": "1", "per_page": "2", }) - fmt.Fprint(w, `{"total_count":2,"codespaces":[{"id":1,"name":"monalisa-octocat-hello-world-g4wpq6h95q","environment_id":"26a7c758-7299-4a73-b978-5a92a7ae98a0","owner":{"login":"octocat"},"billable_owner":{"login":"octocat"},"repository":{"id":1296269},"machine":{"name":"standardLinux","display_name":"4 cores, 8 GB RAM, 64 GB storage","operating_system":"linux","storage_in_bytes":68719476736,"memory_in_bytes":8589934592,"cpus":4},"prebuild":false,"devcontainer_path":".devcontainer/devcontainer.json","created_at":"2021-10-14T00:53:30-06:00","updated_at":"2021-10-14T00:53:32-06:00","last_used_at":"2021-10-14T00:53:30-06:00","state":"Available","url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q","git_status":{"ahead":0,"behind":0,"has_unpushed_changes":false,"has_uncommitted_changes":false,"ref":"main"},"location":"WestUs2","idle_timeout_minutes":60,"web_url":"https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev","machines_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines","start_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start","stop_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop","recent_folders":["testfolder1","testfolder2"]},{"id":2}]}`) + fmt.Fprint(w, `{"total_count":2,"codespaces":[{"id":1,"name":"monalisa-octocat-hello-world-g4wpq6h95q","environment_id":"26a7c758-7299-4a73-b978-5a92a7ae98a0","owner":{"login":"octocat"},"billable_owner":{"login":"octocat"},"repository":{"id":1296269},"machine":{"name":"standardLinux","display_name":"4 cores, 8 GB RAM, 64 GB storage","operating_system":"linux","storage_in_bytes":68719476736,"memory_in_bytes":8589934592,"cpus":4},"prebuild":false,"devcontainer_path":".devcontainer/devcontainer.json","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"last_used_at":`+referenceTimeStr+`,"state":"Available","url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q","git_status":{"ahead":0,"behind":0,"has_unpushed_changes":false,"has_uncommitted_changes":false,"ref":"main"},"location":"WestUs2","idle_timeout_minutes":60,"web_url":"https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev","machines_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines","start_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start","stop_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop","recent_folders":["testfolder1","testfolder2"]},{"id":2}]}`) }) opt := &ListOptions{Page: 1, PerPage: 2} @@ -58,9 +57,9 @@ func TestCodespacesService_ListInRepo(t *testing.T) { }, Prebuild: Ptr(false), DevcontainerPath: Ptr(".devcontainer/devcontainer.json"), - CreatedAt: &Timestamp{time.Date(2021, 10, 14, 0, 53, 30, 0, time.FixedZone("", -6*60*60))}, - UpdatedAt: &Timestamp{time.Date(2021, 10, 14, 0, 53, 32, 0, time.FixedZone("", -6*60*60))}, - LastUsedAt: &Timestamp{time.Date(2021, 10, 14, 0, 53, 30, 0, time.FixedZone("", -6*60*60))}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, + LastUsedAt: &referenceTimestamp, State: Ptr("Available"), URL: Ptr("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q"), GitStatus: &CodespacesGitStatus{ @@ -643,7 +642,7 @@ func TestCodespacesService_ExportCodespace(t *testing.T) { testMethod(t, r, "POST") fmt.Fprint(w, `{ "state": "succeeded", - "completed_at": "2025-12-11T00:00:00Z", + "completed_at": `+referenceTimeStr+`, "branch": "main", "export_url": "https://api.github.com/user/codespaces/:name/exports/latest" }`) @@ -657,7 +656,7 @@ func TestCodespacesService_ExportCodespace(t *testing.T) { want := &CodespaceExport{ State: Ptr("succeeded"), - CompletedAt: Ptr(Timestamp{Time: time.Date(2025, time.December, 11, 0, 0, 0, 0, time.UTC)}), + CompletedAt: &referenceTimestamp, Branch: Ptr("main"), ExportURL: Ptr("https://api.github.com/user/codespaces/:name/exports/latest"), } @@ -684,7 +683,7 @@ func TestCodespacesService_GetLatestCodespaceExport(t *testing.T) { testMethod(t, r, "GET") fmt.Fprint(w, `{ "state": "succeeded", - "completed_at": "2025-12-11T00:00:00Z", + "completed_at": `+referenceTimeStr+`, "branch": "main", "export_url": "https://api.github.com/user/codespaces/:name/exports/latest" }`) @@ -698,7 +697,7 @@ func TestCodespacesService_GetLatestCodespaceExport(t *testing.T) { want := &CodespaceExport{ State: Ptr("succeeded"), - CompletedAt: Ptr(Timestamp{Time: time.Date(2025, time.December, 11, 0, 0, 0, 0, time.UTC)}), + CompletedAt: &referenceTimestamp, Branch: Ptr("main"), ExportURL: Ptr("https://api.github.com/user/codespaces/:name/exports/latest"), } diff --git a/github/copilot_test.go b/github/copilot_test.go index b94ab051406..c5e1b3ebbf1 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -11,7 +11,6 @@ import ( "log" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -357,10 +356,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { "total_seats": 4, "seats": [ { - "created_at": "2021-08-03T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": null, - "last_activity_at": "2021-10-14T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octocat", @@ -399,10 +398,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { } }, { - "created_at": "2021-09-23T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": "2021-10-13T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octokitten", @@ -426,10 +425,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { } }, { - "created_at": "2021-09-23T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": "2021-10-13T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "name": "octokittens", @@ -438,10 +437,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { } }, { - "created_at": "2021-09-23T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": "2021-10-13T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "name": "octocats", @@ -500,10 +499,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Parent: nil, }, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.August, 3, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: nil, - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 14, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -528,10 +527,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { SiteAdmin: Ptr(false), }, AssigningTeam: nil, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 13, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -541,10 +540,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Type: Ptr("Team"), }, AssigningTeam: nil, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 13, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -554,10 +553,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Type: Ptr("Organization"), }, AssigningTeam: nil, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 13, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, }, @@ -595,10 +594,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { "total_seats": 2, "seats": [ { - "created_at": "2021-08-03T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": null, - "last_activity_at": "2021-10-14T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "plan_type": "business", "assignee": { @@ -638,10 +637,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { } }, { - "created_at": "2021-09-23T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": "2021-10-13T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octokitten", @@ -714,10 +713,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), Parent: nil, }, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.August, 3, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: nil, - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 14, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), PlanType: Ptr("business"), }, @@ -743,10 +742,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { SiteAdmin: Ptr(false), }, AssigningTeam: nil, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 13, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), PlanType: nil, }, @@ -1053,10 +1052,10 @@ func TestCopilotService_GetSeatDetails(t *testing.T) { mux.HandleFunc("/orgs/o/members/u/copilot", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{ - "created_at": "2021-08-03T18:00:00-06:00", - "updated_at": "2021-09-23T15:00:00-06:00", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "pending_cancellation_date": null, - "last_activity_at": "2021-10-14T00:53:32-06:00", + "last_activity_at": `+referenceTimeStr+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octocat", @@ -1138,10 +1137,10 @@ func TestCopilotService_GetSeatDetails(t *testing.T) { RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), Parent: nil, }, - CreatedAt: Ptr(Timestamp{time.Date(2021, time.August, 3, 18, 0, 0, 0, time.FixedZone("CST", -6*3600))}), - UpdatedAt: Ptr(Timestamp{time.Date(2021, time.September, 23, 15, 0, 0, 0, time.FixedZone("CST", -6*3600))}), + CreatedAt: Ptr(referenceTimestamp), + UpdatedAt: Ptr(referenceTimestamp), PendingCancellationDate: nil, - LastActivityAt: Ptr(Timestamp{time.Date(2021, time.October, 14, 0, 53, 32, 0, time.FixedZone("CST", -6*3600))}), + LastActivityAt: Ptr(referenceTimestamp), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), } @@ -3169,7 +3168,7 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { "report_start_day": "2026-03-05", "report_end_day": "2026-04-01", "organization_id": "123", - "created_at": "2026-04-02T00:00:00Z", + "created_at": `+referenceTimeStr+`, "day_totals": [ { "day": "2026-03-05", @@ -3210,7 +3209,7 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { ReportStartDay: "2026-03-05", ReportEndDay: "2026-04-01", OrganizationID: Ptr("123"), - CreatedAt: &Timestamp{time.Date(2026, 4, 2, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, DayTotals: []*CopilotDailyMetrics{ { Day: "2026-03-05", @@ -3269,7 +3268,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { mux.HandleFunc("/path/to/users-daily", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"user_id":1,"user_login":"alice","day":"2026-04-01","user_initiated_interaction_count":5,"chat_panel_edit_mode":2,"used_chat":true,"used_cli":true,"used_copilot_code_review_active":true,"totals_by_cli":{"session_count":2,"request_count":2,"prompt_count":1,"last_known_cli_version":{"sampled_at":"2026-04-01T12:30:00Z","cli_version":"1.0.8"}},"totals_by_ide":[{"ide":"vscode","user_initiated_interaction_count":5,"last_known_plugin_version":{"sampled_at":"2026-04-01T12:00:00Z","plugin":"copilot","plugin_version":"1.0.0"},"last_known_ide_version":{"sampled_at":"2026-04-01T12:00:00Z","ide_version":"1.90"}}]} + fmt.Fprint(w, `{"user_id":1,"user_login":"alice","day":"2026-04-01","user_initiated_interaction_count":5,"chat_panel_edit_mode":2,"used_chat":true,"used_cli":true,"used_copilot_code_review_active":true,"totals_by_cli":{"session_count":2,"request_count":2,"prompt_count":1,"last_known_cli_version":{"sampled_at":`+referenceTimeStr+`,"cli_version":"1.0.8"}},"totals_by_ide":[{"ide":"vscode","user_initiated_interaction_count":5,"last_known_plugin_version":{"sampled_at":`+referenceTimeStr+`,"plugin":"copilot","plugin_version":"1.0.0"},"last_known_ide_version":{"sampled_at":`+referenceTimeStr+`,"ide_version":"1.90"}}]} {"user_id":2,"user_login":"bob","day":"2026-04-01","used_agent":true,"used_copilot_code_review_passive":true} `) }) @@ -3301,7 +3300,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { RequestCount: Ptr(2), PromptCount: Ptr(1), LastKnownCLIVersion: &CopilotMetricsCLIVersion{ - SampledAt: &Timestamp{time.Date(2026, 4, 1, 12, 30, 0, 0, time.UTC)}, + SampledAt: &referenceTimestamp, CLIVersion: "1.0.8", }, }, @@ -3310,12 +3309,12 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { IDE: "vscode", UserInitiatedInteractionCount: Ptr(5), LastKnownPluginVersion: &CopilotUserMetricsPluginVersion{ - SampledAt: &Timestamp{time.Date(2026, 4, 1, 12, 0, 0, 0, time.UTC)}, + SampledAt: &referenceTimestamp, Plugin: "copilot", PluginVersion: "1.0.0", }, LastKnownIDEVersion: &CopilotUserMetricsIDEVersion{ - SampledAt: &Timestamp{time.Date(2026, 4, 1, 12, 0, 0, 0, time.UTC)}, + SampledAt: &referenceTimestamp, IDEVersion: "1.90", }, }, diff --git a/github/dependabot_secrets_test.go b/github/dependabot_secrets_test.go index 0a1f8aa3587..de407fb9dde 100644 --- a/github/dependabot_secrets_test.go +++ b/github/dependabot_secrets_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -91,7 +90,7 @@ func TestDependabotService_ListRepoSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/dependabot/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -104,8 +103,8 @@ func TestDependabotService_ListRepoSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, - {Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}}, + {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, }, } if !cmp.Equal(secrets, want) { @@ -133,7 +132,7 @@ func TestDependabotService_GetRepoSecret(t *testing.T) { mux.HandleFunc("/repos/o/r/dependabot/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -144,8 +143,8 @@ func TestDependabotService_GetRepoSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: referenceTimestamp, + UpdatedAt: referenceTimestamp, } if !cmp.Equal(secret, want) { t.Errorf("Dependabot.GetRepoSecret returned %+v, want %+v", secret, want) @@ -275,7 +274,7 @@ func TestDependabotService_ListOrgSecrets(t *testing.T) { mux.HandleFunc("/orgs/o/dependabot/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"all"},{"name":"GH_TOKEN","created_at":"2019-08-10T14:59:22Z","updated_at":"2020-01-10T14:59:22Z","visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}]}`) + fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"all"},{"name":"GH_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -288,9 +287,9 @@ func TestDependabotService_ListOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 3, Secrets: []*Secret{ - {Name: "GIST_ID", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "private"}, - {Name: "DEPLOY_TOKEN", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "all"}, - {Name: "GH_TOKEN", CreatedAt: Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}, + {Name: "GIST_ID", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "private"}, + {Name: "DEPLOY_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "all"}, + {Name: "GH_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}, }, } if !cmp.Equal(secrets, want) { @@ -318,7 +317,7 @@ func TestDependabotService_GetOrgSecret(t *testing.T) { mux.HandleFunc("/orgs/o/dependabot/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z","visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}`) }) ctx := t.Context() @@ -329,8 +328,8 @@ func TestDependabotService_GetOrgSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: Timestamp{time.Date(2019, time.January, 2, 15, 4, 5, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 2, 15, 4, 5, 0, time.UTC)}, + CreatedAt: referenceTimestamp, + UpdatedAt: referenceTimestamp, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories", } diff --git a/github/dependency_graph_snapshots_test.go b/github/dependency_graph_snapshots_test.go index 07ef845944b..ef8f360bada 100644 --- a/github/dependency_graph_snapshots_test.go +++ b/github/dependency_graph_snapshots_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -32,7 +31,7 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { Version: Ptr("0.0.1"), URL: Ptr("https://github.com/octo-org/octo-repo"), }, - Scanned: &Timestamp{time.Date(2022, time.June, 14, 20, 25, 0, 0, time.UTC)}, + Scanned: &referenceTimestamp, Metadata: map[string]any{ "key1": "value1", "key2": "value2", @@ -74,7 +73,7 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { mux.HandleFunc("/repos/o/r/dependency-graph/snapshots", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testJSONBody(t, r, snapshot) - fmt.Fprint(w, `{"id":12345,"created_at":"2022-06-14T20:25:01Z","message":"Dependency results for the repo have been successfully updated.","result":"SUCCESS"}`) + fmt.Fprint(w, `{"id":12345,"created_at":`+referenceTimeStr+`,"message":"Dependency results for the repo have been successfully updated.","result":"SUCCESS"}`) }) ctx := t.Context() @@ -85,7 +84,7 @@ func TestDependencyGraphService_CreateSnapshot(t *testing.T) { want := &DependencyGraphSnapshotCreationData{ ID: 12345, - CreatedAt: &Timestamp{time.Date(2022, time.June, 14, 20, 25, 1, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, Message: Ptr("Dependency results for the repo have been successfully updated."), Result: Ptr("SUCCESS"), } diff --git a/github/dependency_graph_test.go b/github/dependency_graph_test.go index 1bae03b9559..994c87fa18a 100644 --- a/github/dependency_graph_test.go +++ b/github/dependency_graph_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -23,7 +22,7 @@ func TestDependencyGraphService_GetSBOM(t *testing.T) { fmt.Fprint(w, `{ "sbom":{ "creationInfo":{ - "created":"2021-09-01T00:00:00Z" + "created":`+referenceTimeStr+` }, "name":"owner/repo", "packages":[ @@ -42,11 +41,10 @@ func TestDependencyGraphService_GetSBOM(t *testing.T) { t.Errorf("DependencyGraph.GetSBOM returned error: %v", err) } - testTime := time.Date(2021, 9, 1, 0, 0, 0, 0, time.UTC) want := &SBOM{ &SBOMInfo{ CreationInfo: &CreationInfo{ - Created: &Timestamp{testTime}, + Created: &referenceTimestamp, }, Name: Ptr("owner/repo"), Packages: []*RepoDependencies{ diff --git a/github/enterprise_actions_hosted_runners_test.go b/github/enterprise_actions_hosted_runners_test.go index 1575ef22086..abb6df8db6b 100644 --- a/github/enterprise_actions_hosted_runners_test.go +++ b/github/enterprise_actions_hosted_runners_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -48,7 +47,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }, { "id": 7, @@ -69,7 +68,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { "maximum_runners": 20, "public_ip_enabled": false, "public_ips": [], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` } ] }`) @@ -81,8 +80,6 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { t.Errorf("Enterprise.ListHostedRunners returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} - want := &HostedRunners{ TotalCount: 2, Runners: []*HostedRunner{ @@ -111,7 +108,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, }, { ID: Ptr(int64(7)), @@ -132,7 +129,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) { MaximumRunners: Ptr(int64(20)), PublicIPEnabled: Ptr(false), PublicIPs: []*HostedRunnerPublicIP{}, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, }, }, } @@ -186,7 +183,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -209,7 +206,6 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { t.Errorf("Enterprise.CreateHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -235,7 +231,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -614,7 +610,7 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -624,7 +620,6 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) { t.Errorf("Enterprise.GetHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -650,7 +645,7 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -703,7 +698,7 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -721,7 +716,6 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) { t.Errorf("Enterprise.UpdateHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -747,7 +741,7 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -800,7 +794,7 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) { "length": 31 } ], - "last_active_on": "2023-04-26T15:23:37Z" + "last_active_on": `+referenceTimeStr+` }`) }) @@ -810,7 +804,6 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) { t.Errorf("Enterprise.DeleteHostedRunner returned error: %v", err) } - lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)} want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -836,7 +829,7 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -1035,14 +1028,14 @@ func TestEnterpriseService_ListHostedRunnerCustomImageVersions(t *testing.T) { "size_gb": 75, "state": "Ready", "state_details": "None", - "created_on": "2024-11-09T23:39:01Z" + "created_on": `+referenceTimeStr+` }, { "version": "1.0.0", "size_gb": 75, "state": "Ready", "state_details": "None", - "created_on": "2024-11-08T20:39:01Z" + "created_on": `+referenceTimeStr+` } ] }`) @@ -1062,14 +1055,14 @@ func TestEnterpriseService_ListHostedRunnerCustomImageVersions(t *testing.T) { SizeGB: 75, State: "Ready", StateDetails: "None", - CreatedOn: Timestamp{time.Date(2024, 11, 9, 23, 39, 1, 0, time.UTC)}, + CreatedOn: referenceTimestamp, }, { Version: "1.0.0", SizeGB: 75, State: "Ready", StateDetails: "None", - CreatedOn: Timestamp{time.Date(2024, 11, 8, 20, 39, 1, 0, time.UTC)}, + CreatedOn: referenceTimestamp, }, }, } @@ -1104,7 +1097,7 @@ func TestEnterpriseService_GetHostedRunnerCustomImageVersion(t *testing.T) { "size_gb": 75, "state": "Ready", "state_details": "None", - "created_on": "2024-11-08T20:39:01Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -1119,7 +1112,7 @@ func TestEnterpriseService_GetHostedRunnerCustomImageVersion(t *testing.T) { SizeGB: 75, State: "Ready", StateDetails: "None", - CreatedOn: Timestamp{time.Date(2024, 11, 8, 20, 39, 1, 0, time.UTC)}, + CreatedOn: referenceTimestamp, } if !cmp.Equal(version, want) { diff --git a/github/enterprise_actions_runners_test.go b/github/enterprise_actions_runners_test.go index 1e4df2dd142..eb42876ef50 100644 --- a/github/enterprise_actions_runners_test.go +++ b/github/enterprise_actions_runners_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -58,7 +57,7 @@ func TestEnterpriseService_CreateRegistrationToken(t *testing.T) { mux.HandleFunc("/enterprises/e/actions/runners/registration-token", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprint(w, `{"token":"LLBF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":"2020-01-22T12:13:35.123Z"}`) + fmt.Fprint(w, `{"token":"LLBF3JGZDX3P5PMEXLND6TS6FCWO6","expires_at":`+referenceTimeStr+`}`) }) ctx := t.Context() @@ -68,9 +67,8 @@ func TestEnterpriseService_CreateRegistrationToken(t *testing.T) { } want := &RegistrationToken{ - Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), - ExpiresAt: &Timestamp{time.Date(2020, time.January, 22, 12, 13, 35, - 123000000, time.UTC)}, + Token: Ptr("LLBF3JGZDX3P5PMEXLND6TS6FCWO6"), + ExpiresAt: &referenceTimestamp, } if !cmp.Equal(token, want) { t.Errorf("Enterprise.CreateRegistrationToken returned %+v, want %+v", token, want) diff --git a/github/enterprise_licenses_test.go b/github/enterprise_licenses_test.go index dd79c13c775..288e8572e88 100644 --- a/github/enterprise_licenses_test.go +++ b/github/enterprise_licenses_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -120,7 +119,7 @@ func TestEnterpriseService_GetLicenseSyncStatus(t *testing.T) { "last_sync": { "type": "object", "properties": { - "date": "2025-10-30T10:30:00Z", + "date": `+referenceTimeStr+`, "status": "success", "error": "" } @@ -152,7 +151,7 @@ func TestEnterpriseService_GetLicenseSyncStatus(t *testing.T) { LastSync: &LastLicenseSync{ Type: "object", Properties: &LastLicenseSyncProperties{ - Date: &Timestamp{time.Date(2025, 10, 30, 10, 30, 0, 0, time.UTC)}, + Date: &referenceTimestamp, Status: "success", Error: "", }, diff --git a/github/enterprise_manage_ghes_config_test.go b/github/enterprise_manage_ghes_config_test.go index 3c793149585..7f5ececcf4a 100644 --- a/github/enterprise_manage_ghes_config_test.go +++ b/github/enterprise_manage_ghes_config_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -52,7 +51,7 @@ func TestEnterpriseService_Settings(t *testing.T) { "support_key": "ssh-rsa AAAAB3N....", "ssh_allowed": true, "cluster_support": false, - "expire_at": "2018-01-01T00:00:00-00:00" + "expire_at": `+referenceTimeStr+` }, "github_ssl": { "enabled": false, @@ -195,7 +194,7 @@ func TestEnterpriseService_Settings(t *testing.T) { SupportKey: Ptr("ssh-rsa AAAAB3N...."), SSHAllowed: Ptr(true), ClusterSupport: Ptr(false), - ExpireAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + ExpireAt: &referenceTimestamp, }, GithubSSL: &ConfigSettingsGithubSSL{ Enabled: Ptr(false), @@ -415,10 +414,10 @@ func TestEnterpriseService_License(t *testing.T) { "croquetSupport": true, "customTerms": true, "evaluation": false, - "expireAt": "2018-01-01T00:00:00Z", + "expireAt": `+referenceTimeStr+`, "insightsEnabled": true, - "insightsExpireAt": "2018-01-01T00:00:00Z", - "learningLabEvaluationExpires": "2018-01-01T00:00:00Z", + "insightsExpireAt": `+referenceTimeStr+`, + "learningLabEvaluationExpires": `+referenceTimeStr+`, "learningLabSeats": 100, "perpetual": false, "referenceNumber": "32a145", @@ -443,10 +442,10 @@ func TestEnterpriseService_License(t *testing.T) { CroquetSupport: Ptr(true), CustomTerms: Ptr(true), Evaluation: Ptr(false), - ExpireAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + ExpireAt: &referenceTimestamp, InsightsEnabled: Ptr(true), - InsightsExpireAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, - LearningLabEvaluationExpires: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + InsightsExpireAt: &referenceTimestamp, + LearningLabEvaluationExpires: &referenceTimestamp, LearningLabSeats: Ptr(100), Perpetual: Ptr(false), ReferenceNumber: Ptr("32a145"), @@ -479,7 +478,7 @@ func TestEnterpriseService_ConfigApplyEvents(t *testing.T) { "node": "ghes-01.lan", "last_request_id": "387cd628c06d606700e79be368e5e574:0cde553750689c76:0000000000000000", "events": [{ - "timestamp": "2018-01-01T00:00:00+00:00", + "timestamp": `+referenceTimeStr+`, "severity_text": "INFO", "body": "Validating services", "event_name": "Enterprise::ConfigApply::PhaseValidation#config_phase_validation", @@ -510,7 +509,7 @@ func TestEnterpriseService_ConfigApplyEvents(t *testing.T) { Node: Ptr("ghes-01.lan"), LastRequestID: Ptr("387cd628c06d606700e79be368e5e574:0cde553750689c76:0000000000000000"), Events: []*ConfigApplyEventsNodeEvent{{ - Timestamp: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + Timestamp: &referenceTimestamp, SeverityText: Ptr("INFO"), Body: Ptr("Validating services"), EventName: Ptr("Enterprise::ConfigApply::PhaseValidation#config_phase_validation"), diff --git a/github/enterprise_manage_ghes_maintenance_test.go b/github/enterprise_manage_ghes_maintenance_test.go index 82abacb7d0e..0a3f3cf559d 100644 --- a/github/enterprise_manage_ghes_maintenance_test.go +++ b/github/enterprise_manage_ghes_maintenance_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -28,7 +27,7 @@ func TestEnterpriseService_GetMaintenanceStatus(t *testing.T) { "hostname": "primary", "uuid": "1b6cf518-f97c-11ed-8544-061d81f7eedb", "status": "scheduled", - "scheduled_time": "2018-01-01T00:00:00+00:00", + "scheduled_time": `+referenceTimeStr+`, "connection_services": [ { "name": "git operations", @@ -56,7 +55,7 @@ func TestEnterpriseService_GetMaintenanceStatus(t *testing.T) { Hostname: Ptr("primary"), UUID: Ptr("1b6cf518-f97c-11ed-8544-061d81f7eedb"), Status: Ptr("scheduled"), - ScheduledTime: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + ScheduledTime: &referenceTimestamp, ConnectionServices: []*ConnectionServiceItem{{ Name: Ptr("git operations"), Number: Ptr(15), diff --git a/github/enterprise_network_configurations_test.go b/github/enterprise_network_configurations_test.go index 43e1602298f..c4154b5f654 100644 --- a/github/enterprise_network_configurations_test.go +++ b/github/enterprise_network_configurations_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -32,7 +31,7 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) { "23456789ABDCEF1", "3456789ABDCEF12" ], - "created_on": "2024-04-09T17:30:15Z" + "created_on": `+referenceTimeStr+` }, { "id": "456789ABDCEF123", @@ -42,7 +41,7 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345" ], - "created_on": "2024-11-02T12:30:30Z" + "created_on": `+referenceTimeStr+` } ] }`) @@ -64,14 +63,14 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) { Name: Ptr("configuration one"), ComputeService: Ptr(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1", "3456789ABDCEF12"}, - CreatedOn: &Timestamp{time.Date(2024, 4, 9, 17, 30, 15, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, }, { ID: Ptr("456789ABDCEF123"), Name: Ptr("configuration two"), ComputeService: Ptr(ComputeService("none")), NetworkSettingsIDs: []string{"56789ABDCEF1234", "6789ABDCEF12345"}, - CreatedOn: &Timestamp{time.Date(2024, 11, 2, 12, 30, 30, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, }, }, } @@ -107,7 +106,7 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { "network_settings_ids": [ "23456789ABDCEF1" ], - "created_on": "2024-04-09T17:30:15Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -130,7 +129,7 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { Name: Ptr("configuration one"), ComputeService: Ptr(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1"}, - CreatedOn: &Timestamp{time.Date(2024, 4, 9, 17, 30, 15, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, } if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.CreateEnterpriseNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) @@ -202,7 +201,7 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) { "23456789ABDCEF1", "3456789ABDCEF12" ], - "created_on": "2024-12-10T19:00:15Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -217,7 +216,7 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) { Name: Ptr("configuration one"), ComputeService: Ptr(ComputeService("actions")), NetworkSettingsIDs: []string{"23456789ABDCEF1", "3456789ABDCEF12"}, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 0, 15, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, } if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.GetEnterpriseNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) @@ -251,7 +250,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { "network_settings_ids": [ "456789ABDCEF123" ], - "created_on": "2024-12-10T19:00:15Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -273,7 +272,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { Name: Ptr("updated configuration one"), ComputeService: Ptr(ComputeService("none")), NetworkSettingsIDs: []string{"456789ABDCEF123"}, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 0, 15, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, } if !cmp.Equal(configuration, want) { t.Errorf("Enterprise.UpdateEnterpriseNetworkConfiguration mismatch (-want +get)\n%v", cmp.Diff(want, configuration)) diff --git a/github/enterprise_team_test.go b/github/enterprise_team_test.go index b79f8c3a793..0b9bbb1265f 100644 --- a/github/enterprise_team_test.go +++ b/github/enterprise_team_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -27,8 +26,8 @@ func TestEnterpriseService_ListTeams(t *testing.T) { "name": "Team One", "html_url": "https://example.com/html", "slug": "team-one", - "created_at": "2020-01-01T00:00:00Z", - "updated_at": "2020-01-02T00:00:00Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "group_id": "99" }]`) }) @@ -49,8 +48,8 @@ func TestEnterpriseService_ListTeams(t *testing.T) { HTMLURL: "https://example.com/html", Slug: "team-one", GroupID: "99", - CreatedAt: Timestamp{Time: time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC)}, - UpdatedAt: Timestamp{Time: time.Date(2020, time.January, 2, 0, 0, 0, 0, time.UTC)}, + CreatedAt: referenceTimestamp, + UpdatedAt: referenceTimestamp, }, } diff --git a/github/gists_test.go b/github/gists_test.go index 39928c0d2bc..0ed629dd482 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -18,17 +17,15 @@ func TestGistsService_List_specifiedUser(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - since := "2013-01-01T00:00:00Z" - mux.HandleFunc("/users/u/gists", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{ - "since": since, + "since": referenceTimeRaw, }) fmt.Fprint(w, `[{"id": "1"}]`) }) - opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)} + opt := &GistListOptions{Since: referenceTime} ctx := t.Context() gists, _, err := client.Gists.List(ctx, "u", opt) if err != nil { @@ -103,17 +100,15 @@ func TestGistsService_ListAll(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - since := "2013-01-01T00:00:00Z" - mux.HandleFunc("/gists/public", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{ - "since": since, + "since": referenceTimeRaw, }) fmt.Fprint(w, `[{"id": "1"}]`) }) - opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)} + opt := &GistListOptions{Since: referenceTime} ctx := t.Context() gists, _, err := client.Gists.ListAll(ctx, opt) if err != nil { @@ -139,17 +134,15 @@ func TestGistsService_ListStarred(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - since := "2013-01-01T00:00:00Z" - mux.HandleFunc("/gists/starred", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{ - "since": since, + "since": referenceTimeRaw, }) fmt.Fprint(w, `[{"id": "1"}]`) }) - opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)} + opt := &GistListOptions{Since: referenceTime} ctx := t.Context() gists, _, err := client.Gists.ListStarred(ctx, opt) if err != nil { @@ -412,7 +405,7 @@ func TestGistsService_ListCommits(t *testing.T) { "additions": 180, "total": 180 }, - "committed_at": "2010-01-01T00:00:00Z" + "committed_at": `+referenceTimeStr+` } ] `) @@ -428,7 +421,7 @@ func TestGistsService_ListCommits(t *testing.T) { URL: Ptr("https://api.github.com/gists/1/1"), Version: Ptr("1"), User: &User{ID: Ptr(int64(1))}, - CommittedAt: &Timestamp{time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC)}, + CommittedAt: &referenceTimestamp, ChangeStatus: &CommitStats{ Additions: Ptr(180), Deletions: Ptr(0), @@ -721,8 +714,8 @@ func TestGistsService_ListForks(t *testing.T) { {"url": "https://api.github.com/gists/1", "user": {"id": 1}, "id": "1", - "created_at": "2010-01-01T00:00:00Z", - "updated_at": "2013-01-01T00:00:00Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` } ] `) @@ -738,8 +731,8 @@ func TestGistsService_ListForks(t *testing.T) { URL: Ptr("https://api.github.com/gists/1"), ID: Ptr("1"), User: &User{ID: Ptr(int64(1))}, - CreatedAt: &Timestamp{time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, }} if !cmp.Equal(gistForks, want) { diff --git a/github/git_commits_test.go b/github/git_commits_test.go index f7febde7246..6a8ef8ceafe 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -11,7 +11,6 @@ import ( "io" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -202,16 +201,15 @@ func TestGitService_CreateCommit_WithSigner(t *testing.T) { client, mux, _ := setup(t) signature := "my voice is my password" - date := time.Date(2017, time.May, 4, 0, 3, 43, 0, time.FixedZone("CEST", 2*3600)) author := CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &Timestamp{date}, + Date: &referenceTimestamp, } wantMessage := `tree t parent p -author go-github 1493849023 +0200 -committer go-github 1493849023 +0200 +author go-github ` + referenceUnixTimeStr + ` +0000 +committer go-github ` + referenceUnixTimeStr + ` +0000 Commit Message.` sha := "commitSha" @@ -295,15 +293,13 @@ func TestGitService_createSignatureMessage_nilCommit(t *testing.T) { func TestGitService_createSignatureMessage_nilMessage(t *testing.T) { t.Parallel() - date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") - _, err := createSignatureMessage(&createCommit{ Message: nil, Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &Timestamp{date}, + Date: &referenceTimestamp, }, }) if err == nil { @@ -313,14 +309,13 @@ func TestGitService_createSignatureMessage_nilMessage(t *testing.T) { func TestGitService_createSignatureMessage_emptyMessage(t *testing.T) { t.Parallel() - date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") _, err := createSignatureMessage(&createCommit{ Message: Ptr(""), Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &Timestamp{date}, + Date: &referenceTimestamp, }, }) if err == nil { @@ -342,20 +337,18 @@ func TestGitService_createSignatureMessage_nilAuthor(t *testing.T) { func TestGitService_createSignatureMessage_withoutTree(t *testing.T) { t.Parallel() - date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") - msg, _ := createSignatureMessage(&createCommit{ Message: Ptr("Commit Message."), Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &Timestamp{date}, + Date: &referenceTimestamp, }, }) expected := `parent p -author go-github 1493849023 +0200 -committer go-github 1493849023 +0200 +author go-github ` + referenceUnixTimeStr + ` +0000 +committer go-github ` + referenceUnixTimeStr + ` +0000 Commit Message.` if msg != expected { @@ -365,25 +358,23 @@ Commit Message.` func TestGitService_createSignatureMessage_withoutCommitter(t *testing.T) { t.Parallel() - date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") - msg, _ := createSignatureMessage(&createCommit{ Message: Ptr("Commit Message."), Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &Timestamp{date}, + Date: &referenceTimestamp, }, Committer: &CommitAuthor{ Name: Ptr("foo"), Email: Ptr("foo@example.com"), - Date: &Timestamp{date}, + Date: &referenceTimestamp, }, }) expected := `parent p -author go-github 1493849023 +0200 -committer foo 1493849023 +0200 +author go-github ` + referenceUnixTimeStr + ` +0000 +committer foo ` + referenceUnixTimeStr + ` +0000 Commit Message.` if msg != expected { diff --git a/github/github_test.go b/github/github_test.go index 5d47371105f..6d82a59bb1b 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -2424,7 +2424,7 @@ func TestDo_rateLimit(t *testing.T) { w.Header().Set(HeaderRateLimit, "60") w.Header().Set(HeaderRateRemaining, "59") w.Header().Set(HeaderRateUsed, "1") - w.Header().Set(HeaderRateReset, "1372700873") + w.Header().Set(HeaderRateReset, referenceUnixTimeStr) w.Header().Set(HeaderRateResource, "core") }) @@ -2442,9 +2442,8 @@ func TestDo_rateLimit(t *testing.T) { if got, want := resp.Rate.Used, 1; got != want { t.Errorf("Client rate used = %v, want %v", got, want) } - reset := time.Date(2013, time.July, 1, 17, 47, 53, 0, time.UTC) - if !resp.Rate.Reset.UTC().Equal(reset) { - t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset.UTC(), reset) + if !resp.Rate.Reset.UTC().Equal(referenceTime) { + t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset.UTC(), referenceTime) } if got, want := resp.Rate.Resource, "core"; got != want { t.Errorf("Client rate resource = %v, want %v", got, want) @@ -2542,7 +2541,7 @@ func TestDo_rateLimit_errorResponse(t *testing.T) { w.Header().Set(HeaderRateLimit, "60") w.Header().Set(HeaderRateRemaining, "59") w.Header().Set(HeaderRateUsed, "1") - w.Header().Set(HeaderRateReset, "1372700873") + w.Header().Set(HeaderRateReset, referenceUnixTimeStr) w.Header().Set(HeaderRateResource, "core") http.Error(w, "Bad Request", 400) }) @@ -2564,9 +2563,8 @@ func TestDo_rateLimit_errorResponse(t *testing.T) { if got, want := resp.Rate.Used, 1; got != want { t.Errorf("Client rate used = %v, want %v", got, want) } - reset := time.Date(2013, time.July, 1, 17, 47, 53, 0, time.UTC) - if !resp.Rate.Reset.UTC().Equal(reset) { - t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset, reset) + if !resp.Rate.Reset.UTC().Equal(referenceTime) { + t.Errorf("Client rate reset = %v, want %v", resp.Rate.Reset, referenceTime) } if got, want := resp.Rate.Resource, "core"; got != want { t.Errorf("Client rate resource = %v, want %v", got, want) @@ -2582,7 +2580,7 @@ func TestDo_rateLimit_rateLimitError(t *testing.T) { w.Header().Set(HeaderRateLimit, "60") w.Header().Set(HeaderRateRemaining, "0") w.Header().Set(HeaderRateUsed, "60") - w.Header().Set(HeaderRateReset, "1372700873") + w.Header().Set(HeaderRateReset, referenceUnixTimeStr) w.Header().Set(HeaderRateResource, "core") w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(http.StatusForbidden) @@ -2611,9 +2609,8 @@ func TestDo_rateLimit_rateLimitError(t *testing.T) { if got, want := rateLimitErr.Rate.Used, 60; got != want { t.Errorf("rateLimitErr rate used = %v, want %v", got, want) } - reset := time.Date(2013, time.July, 1, 17, 47, 53, 0, time.UTC) - if !rateLimitErr.Rate.Reset.UTC().Equal(reset) { - t.Errorf("rateLimitErr rate reset = %v, want %v", rateLimitErr.Rate.Reset.UTC(), reset) + if !rateLimitErr.Rate.Reset.UTC().Equal(referenceTime) { + t.Errorf("rateLimitErr rate reset = %v, want %v", rateLimitErr.Rate.Reset.UTC(), referenceTime) } if got, want := rateLimitErr.Rate.Resource, "core"; got != want { t.Errorf("rateLimitErr rate resource = %v, want %v", got, want) @@ -3457,7 +3454,7 @@ func TestCheckResponse(t *testing.T) { StatusCode: http.StatusBadRequest, Body: io.NopCloser(strings.NewReader(`{"message":"m", "errors": [{"resource": "r", "field": "f", "code": "c"}], - "block": {"reason": "dmca", "created_at": "2016-03-17T15:39:46Z"}}`)), + "block": {"reason": "dmca", "created_at": ` + referenceTimeStr + `}}`)), } var err *ErrorResponse errors.As(CheckResponse(res), &err) @@ -3472,7 +3469,7 @@ func TestCheckResponse(t *testing.T) { Errors: []Error{{Resource: "r", Field: "f", Code: "c"}}, Block: &ErrorBlock{ Reason: "dmca", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, } if !errors.Is(err, want) { @@ -3685,7 +3682,7 @@ func TestErrorResponse_Is(t *testing.T) { Errors: []Error{{Resource: "r", Field: "f", Code: "c"}}, Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", } @@ -3701,7 +3698,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m", Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", }, @@ -3714,7 +3711,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m1", Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", }, @@ -3727,7 +3724,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m", Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://google.com", }, @@ -3739,7 +3736,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m", Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", }, @@ -3752,7 +3749,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m", Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", }, @@ -3765,7 +3762,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m", Block: &ErrorBlock{ Reason: "r", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", }, @@ -3787,7 +3784,7 @@ func TestErrorResponse_Is(t *testing.T) { Message: "m", Block: &ErrorBlock{ Reason: "r1", - CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, }, DocumentationURL: "https://github.com", }, diff --git a/github/issue_import_test.go b/github/issue_import_test.go index 1b7149a983d..e3509145206 100644 --- a/github/issue_import_test.go +++ b/github/issue_import_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -19,18 +18,17 @@ func TestIssueImportService_Create(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - createdAt := time.Date(2020, time.August, 11, 15, 30, 0, 0, time.UTC) input := &IssueImportRequest{ IssueImport: IssueImport{ Assignee: Ptr("developer"), Body: "Dummy description", - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Labels: []string{"l1", "l2"}, Milestone: Ptr(1), Title: "Dummy Issue", }, Comments: []*Comment{{ - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Body: "Comment body", }}, } @@ -72,18 +70,17 @@ func TestIssueImportService_Create_deferred(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - createdAt := time.Date(2020, time.August, 11, 15, 30, 0, 0, time.UTC) input := &IssueImportRequest{ IssueImport: IssueImport{ Assignee: Ptr("developer"), Body: "Dummy description", - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Labels: []string{"l1", "l2"}, Milestone: Ptr(1), Title: "Dummy Issue", }, Comments: []*Comment{{ - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Body: "Comment body", }}, } @@ -113,18 +110,17 @@ func TestIssueImportService_Create_badResponse(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - createdAt := time.Date(2020, time.August, 11, 15, 30, 0, 0, time.UTC) input := &IssueImportRequest{ IssueImport: IssueImport{ Assignee: Ptr("developer"), Body: "Dummy description", - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Labels: []string{"l1", "l2"}, Milestone: Ptr(1), Title: "Dummy Issue", }, Comments: []*Comment{{ - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Body: "Comment body", }}, } @@ -212,7 +208,7 @@ func TestIssueImportService_CheckStatusSince(t *testing.T) { }) ctx := t.Context() - got, _, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", Timestamp{time.Now()}) + got, _, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", referenceTimestamp) if err != nil { t.Errorf("CheckStatusSince returned error: %v", err) } @@ -224,12 +220,12 @@ func TestIssueImportService_CheckStatusSince(t *testing.T) { const methodName = "CheckStatusSince" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.IssueImport.CheckStatusSince(ctx, "\n", "\n", Timestamp{time.Now()}) + _, _, err = client.IssueImport.CheckStatusSince(ctx, "\n", "\n", referenceTimestamp) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", Timestamp{time.Now()}) + got, resp, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", referenceTimestamp) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -249,7 +245,7 @@ func TestIssueImportService_CheckStatusSince_badResponse(t *testing.T) { }) ctx := t.Context() - if _, _, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", Timestamp{time.Now()}); err == nil { + if _, _, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", referenceTimestamp); err == nil { t.Error("CheckStatusSince returned no error, want JSON err") } } @@ -259,7 +255,7 @@ func TestIssueImportService_CheckStatusSince_invalidOwner(t *testing.T) { client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.IssueImport.CheckStatusSince(ctx, "%", "r", Timestamp{time.Now()}) + _, _, err := client.IssueImport.CheckStatusSince(ctx, "%", "r", referenceTimestamp) testURLParseError(t, err) } diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index 4f20ee753b5..70a317b5308 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -24,17 +23,16 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { testFormValues(t, r, values{ "sort": "updated", "direction": "desc", - "since": "2002-02-10T15:30:00Z", + "since": referenceTimeRaw, "page": "2", }) fmt.Fprint(w, `[{"id":1}]`) }) - since := time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC) opt := &IssueListCommentsOptions{ Sort: Ptr("updated"), Direction: Ptr("desc"), - Since: &since, + Since: &referenceTime, ListOptions: ListOptions{Page: 2}, } ctx := t.Context() diff --git a/github/issues_test.go b/github/issues_test.go index e4da6c72c49..3d129fd83ed 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -27,7 +26,7 @@ func TestIssuesService_ListAllIssues(t *testing.T) { "labels": "a,b", "sort": "updated", "direction": "asc", - "since": "2026-01-02T00:00:00Z", + "since": referenceTimeRaw, "collab": "true", "orgs": "true", "owned": "true", @@ -44,7 +43,7 @@ func TestIssuesService_ListAllIssues(t *testing.T) { Labels: []string{"a", "b"}, Sort: "updated", Direction: "asc", - Since: time.Date(2026, time.January, 2, 0, 0, 0, 0, time.UTC), + Since: referenceTime, Collab: true, Orgs: true, Owned: true, @@ -85,7 +84,7 @@ func TestIssuesService_ListUserIssues(t *testing.T) { "labels": "a,b", "sort": "updated", "direction": "asc", - "since": "2026-01-02T00:00:00Z", + "since": referenceTimeRaw, "per_page": "4", "page": "2", }) @@ -99,7 +98,7 @@ func TestIssuesService_ListUserIssues(t *testing.T) { Labels: []string{"a", "b"}, Sort: "updated", Direction: "asc", - Since: time.Date(2026, time.January, 2, 0, 0, 0, 0, time.UTC), + Since: referenceTime, ListOptions: ListOptions{Page: 2, PerPage: 4}, } issues, _, err := client.Issues.ListUserIssues(ctx, opts) @@ -135,7 +134,7 @@ func TestIssuesService_ListByOrg(t *testing.T) { "type": "bug", "sort": "updated", "direction": "asc", - "since": "2026-01-02T00:00:00Z", + "since": referenceTimeRaw, "per_page": "4", "page": "2", }) @@ -151,7 +150,7 @@ func TestIssuesService_ListByOrg(t *testing.T) { Type: "bug", Sort: "updated", Direction: "asc", - Since: time.Date(2026, time.January, 2, 0, 0, 0, 0, time.UTC), + Since: referenceTime, ListOptions: ListOptions{Page: 2, PerPage: 4}, } issues, _, err := client.Issues.ListByOrg(ctx, "o", opts) @@ -195,7 +194,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { "labels": "a,b", "sort": "updated", "direction": "asc", - "since": referenceTime.Format(time.RFC3339), + "since": referenceTimeRaw, "per_page": "1", }) fmt.Fprint(w, `[{"number":1}]`) diff --git a/github/orgs_credential_authorizations_test.go b/github/orgs_credential_authorizations_test.go index 40f35b3c4a6..7938a9de100 100644 --- a/github/orgs_credential_authorizations_test.go +++ b/github/orgs_credential_authorizations_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -26,8 +25,8 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { "login": "l", "credential_id": 1, "credential_type": "t", - "credential_authorized_at": "2017-01-21T00:00:00Z", - "credential_accessed_at": "2017-01-21T00:00:00Z", + "credential_authorized_at": `+referenceTimeStr+`, + "credential_accessed_at": `+referenceTimeStr+`, "authorized_credential_id": 1 } ]`) @@ -44,14 +43,13 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { t.Errorf("Organizations.ListCredentialAuthorizations returned error: %v", err) } - ts := time.Date(2017, time.January, 21, 0, 0, 0, 0, time.UTC) want := []*CredentialAuthorization{ { Login: Ptr("l"), CredentialID: Ptr(int64(1)), CredentialType: Ptr("t"), - CredentialAuthorizedAt: &Timestamp{ts}, - CredentialAccessedAt: &Timestamp{ts}, + CredentialAuthorizedAt: &referenceTimestamp, + CredentialAccessedAt: &referenceTimestamp, AuthorizedCredentialID: Ptr(int64(1)), }, } diff --git a/github/orgs_custom_repository_roles_test.go b/github/orgs_custom_repository_roles_test.go index e1acd7ff92b..ea25ad915ea 100644 --- a/github/orgs_custom_repository_roles_test.go +++ b/github/orgs_custom_repository_roles_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -38,8 +37,8 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) { "location": "l", "email": "e" }, - "created_at": "2024-07-21T19:33:08Z", - "updated_at": "2024-07-21T19:33:08Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` } ] }`) @@ -71,8 +70,8 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) { Location: Ptr("l"), Email: Ptr("e"), }, - CreatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, }, }, } @@ -118,8 +117,8 @@ func TestOrganizationsService_GetCustomRepoRole(t *testing.T) { "location": "l", "email": "e" }, - "created_at": "2024-07-21T19:33:08Z", - "updated_at": "2024-07-21T19:33:08Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -146,8 +145,8 @@ func TestOrganizationsService_GetCustomRepoRole(t *testing.T) { Location: Ptr("l"), Email: Ptr("e"), }, - CreatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(role, want) { t.Errorf("Organizations.GetCustomRepoRole returned %+v, want %+v", role, want) diff --git a/github/orgs_issue_types_test.go b/github/orgs_issue_types_test.go index 72c1b0ae0c1..856bd182187 100644 --- a/github/orgs_issue_types_test.go +++ b/github/orgs_issue_types_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -26,16 +25,16 @@ func TestOrganizationsService_ListIssueTypes(t *testing.T) { "node_id": "IT_kwDNAd3NAZo", "name": "Task", "description": "A specific piece of work", - "created_at": "2024-12-11T14:39:09Z", - "updated_at": "2024-12-11T14:39:09Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }, { "id": 411, "node_id": "IT_kwDNAd3NAZs", "name": "Bug", "description": "An unexpected problem or behavior", - "created_at": "2024-12-11T14:39:09Z", - "updated_at": "2024-12-11T14:39:09Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` } ]`) }) @@ -52,16 +51,16 @@ func TestOrganizationsService_ListIssueTypes(t *testing.T) { NodeID: Ptr("IT_kwDNAd3NAZo"), Name: Ptr("Task"), Description: Ptr("A specific piece of work"), - CreatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), - UpdatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, }, { ID: Ptr(int64(411)), NodeID: Ptr("IT_kwDNAd3NAZs"), Name: Ptr("Bug"), Description: Ptr("An unexpected problem or behavior"), - CreatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), - UpdatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, }, } if !cmp.Equal(issueTypes, want) { @@ -103,8 +102,8 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { "node_id": "IT_kwDNAd3NAZo", "name": "Epic", "description": "An issue type for a multi-week tracking of work", - "created_at": "2024-12-11T14:39:09Z", - "updated_at": "2024-12-11T14:39:09Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -118,8 +117,8 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { NodeID: Ptr("IT_kwDNAd3NAZo"), Name: Ptr("Epic"), Description: Ptr("An issue type for a multi-week tracking of work"), - CreatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), - UpdatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(issueType, want) { @@ -161,8 +160,8 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { "node_id": "IT_kwDNAd3NAZo", "name": "Epic", "description": "An issue type for a multi-week tracking of work", - "created_at": "2024-12-11T14:39:09Z", - "updated_at": "2024-12-11T14:39:09Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -176,8 +175,8 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { NodeID: Ptr("IT_kwDNAd3NAZo"), Name: Ptr("Epic"), Description: Ptr("An issue type for a multi-week tracking of work"), - CreatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), - UpdatedAt: Ptr(Timestamp{time.Date(2024, 12, 11, 14, 39, 9, 0, time.UTC)}), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(issueType, want) { diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 7e77f1de3bb..89592c0fea3 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -562,7 +561,7 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { "login": "monalisa", "email": "octocat@github.com", "role": "direct_member", - "created_at": "2017-01-21T00:00:00Z", + "created_at": `+referenceTimeStr+`, "inviter": { "login": "other_user", "id": 1, @@ -595,14 +594,13 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingOrgInvitations returned error: %v", err) } - createdAt := time.Date(2017, time.January, 21, 0, 0, 0, 0, time.UTC) want := []*Invitation{ { ID: Ptr(int64(1)), Login: Ptr("monalisa"), Email: Ptr("octocat@github.com"), Role: Ptr("direct_member"), - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Inviter: &User{ Login: Ptr("other_user"), ID: Ptr(int64(1)), @@ -767,8 +765,8 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { "node_id":"MDQ6VXNlcjE=", "email":"octocat@github.com", "role":"direct_member", - "created_at":"2016-11-30T06:46:10Z", - "failed_at":"2017-01-02T01:10:00Z", + "created_at":`+referenceTimeStr+`, + "failed_at":`+referenceTimeStr+`, "failed_reason":"the reason", "inviter":{ "login":"other_user", @@ -803,7 +801,6 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { t.Errorf("Organizations.ListFailedOrgInvitations returned error: %v", err) } - createdAt := time.Date(2016, time.November, 30, 6, 46, 10, 0, time.UTC) want := []*Invitation{ { ID: Ptr(int64(1)), @@ -811,9 +808,9 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { NodeID: Ptr("MDQ6VXNlcjE="), Email: Ptr("octocat@github.com"), Role: Ptr("direct_member"), - FailedAt: &Timestamp{time.Date(2017, time.January, 2, 1, 10, 0, 0, time.UTC)}, + FailedAt: &referenceTimestamp, FailedReason: Ptr("the reason"), - CreatedAt: &Timestamp{createdAt}, + CreatedAt: &referenceTimestamp, Inviter: &User{ Login: Ptr("other_user"), ID: Ptr(int64(1)), diff --git a/github/orgs_network_configurations_test.go b/github/orgs_network_configurations_test.go index 5a34238b78a..cb2767cfe51 100644 --- a/github/orgs_network_configurations_test.go +++ b/github/orgs_network_configurations_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -32,7 +31,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { "23456789ABDCEF1", "3456789ABDCEF12" ], - "created_on": "2024-04-09T17:30:15Z" + "created_on": `+referenceTimeStr+` }, { "id": "456789ABDCEF123", @@ -42,7 +41,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345" ], - "created_on": "2024-11-02T4:30:30Z" + "created_on": `+referenceTimeStr+` }, { "id": "789ABDCEF123456", @@ -52,7 +51,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345" ], - "created_on": "2024-12-10T19:30:45Z" + "created_on": `+referenceTimeStr+` } ] }`) @@ -76,7 +75,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { "23456789ABDCEF1", "3456789ABDCEF12", }, - CreatedOn: &Timestamp{time.Date(2024, 4, 9, 17, 30, 15, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, }, { ID: Ptr("456789ABDCEF123"), @@ -86,7 +85,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345", }, - CreatedOn: &Timestamp{time.Date(2024, 11, 2, 4, 30, 30, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, }, { ID: Ptr("789ABDCEF123456"), @@ -96,7 +95,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345", }, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 30, 45, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, }, }, } @@ -132,7 +131,7 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { "network_settings_ids": [ "56789ABDCEF1234" ], - "created_on": "2024-11-02T4:30:30Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -158,7 +157,7 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { NetworkSettingsIDs: []string{ "56789ABDCEF1234", }, - CreatedOn: &Timestamp{time.Date(2024, 11, 2, 4, 30, 30, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, } if !cmp.Equal(want, configuration) { @@ -253,7 +252,7 @@ func TestOrganizationsService_GetOrgsNetworkConfiguration(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345" ], - "created_on": "2024-12-10T19:30:45Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -271,7 +270,7 @@ func TestOrganizationsService_GetOrgsNetworkConfiguration(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345", }, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 30, 45, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, } if !cmp.Equal(want, configuration) { t.Errorf("Organizations.GetNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) @@ -306,7 +305,7 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345" ], - "created_on": "2024-12-10T19:30:45Z" + "created_on": `+referenceTimeStr+` }`) }) @@ -332,7 +331,7 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { "56789ABDCEF1234", "6789ABDCEF12345", }, - CreatedOn: &Timestamp{time.Date(2024, 12, 10, 19, 30, 45, 0, time.UTC)}, + CreatedOn: &referenceTimestamp, } if !cmp.Equal(want, configuration) { t.Errorf("Organizations.UpdateNetworkConfiguration mismatch (-want +got):\n%v", cmp.Diff(want, configuration)) diff --git a/github/orgs_organization_roles_test.go b/github/orgs_organization_roles_test.go index 4b5c0ce0180..35e5769a6d5 100644 --- a/github/orgs_organization_roles_test.go +++ b/github/orgs_organization_roles_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -37,8 +36,8 @@ func TestOrganizationsService_ListRoles(t *testing.T) { "location": "l", "email": "e" }, - "created_at": "2024-07-21T19:33:08Z", - "updated_at": "2024-07-21T19:33:08Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "source": "Organization", "base_role": "admin" } @@ -71,8 +70,8 @@ func TestOrganizationsService_ListRoles(t *testing.T) { Location: Ptr("l"), Email: Ptr("e"), }, - CreatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Source: Ptr("Organization"), BaseRole: Ptr("admin"), }, @@ -128,8 +127,8 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { Name: Ptr("all_repo_read"), Description: Ptr("Grants read access to all repositories in the organization."), Permissions: []string{}, - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Source: Ptr("Predefined"), BaseRole: Ptr("read"), } @@ -171,8 +170,8 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { "read_organization_custom_repo_role", "write_organization_custom_org_role", }, - CreatedAt: &Timestamp{referenceTime}, - UpdatedAt: &Timestamp{referenceTime}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Source: Ptr("Organization"), BaseRole: nil, } diff --git a/github/orgs_personal_access_tokens_test.go b/github/orgs_personal_access_tokens_test.go index 0cbc2ba1486..1607e1460a5 100644 --- a/github/orgs_personal_access_tokens_test.go +++ b/github/orgs_personal_access_tokens_test.go @@ -10,7 +10,6 @@ import ( "net/http" "net/url" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -63,9 +62,9 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokens(t *testing.T) "metadata": "read" } }, - "access_granted_at": "2023-05-16T08:47:09.000-07:00", + "access_granted_at": `+referenceTimeStr+`, "token_expired": false, - "token_expires_at": "2023-11-16T08:47:09.000-07:00", + "token_expires_at": `+referenceTimeStr+`, "token_last_used_at": null } ]`) @@ -112,9 +111,9 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokens(t *testing.T) Org: map[string]string{"members": "read"}, Repo: map[string]string{"metadata": "read"}, }, - AccessGrantedAt: &Timestamp{time.Date(2023, time.May, 16, 8, 47, 9, 0, time.FixedZone("PDT", -7*60*60))}, + AccessGrantedAt: &referenceTimestamp, TokenExpired: Ptr(false), - TokenExpiresAt: &Timestamp{time.Date(2023, time.November, 16, 8, 47, 9, 0, time.FixedZone("PDT", -7*60*60))}, + TokenExpiresAt: &referenceTimestamp, TokenLastUsedAt: nil, }, } @@ -210,11 +209,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokenRequests(t *test "metadata": "read" } }, - "created_at": "2026-02-17T06:49:30Z", + "created_at": `+referenceTimeStr+`, "token_id": 11579703, "token_name": "testFineGrained", "token_expired": false, - "token_expires_at": "2026-04-18T06:49:30Z", + "token_expires_at": `+referenceTimeStr+`, "token_last_used_at": null } ]`) @@ -262,11 +261,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokenRequests(t *test Permissions: PersonalAccessTokenPermissions{ Repo: map[string]string{"metadata": "read"}, }, - CreatedAt: &Timestamp{time.Date(2026, time.February, 17, 6, 49, 30, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, TokenID: 11579703, TokenName: "testFineGrained", TokenExpired: false, - TokenExpiresAt: &Timestamp{time.Date(2026, time.April, 18, 6, 49, 30, 0, time.UTC)}, + TokenExpiresAt: &referenceTimestamp, TokenLastUsedAt: nil, }, } diff --git a/github/private_registries_test.go b/github/private_registries_test.go index fccb6af0b25..0c72c5a0c4f 100644 --- a/github/private_registries_test.go +++ b/github/private_registries_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -32,8 +31,8 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T "name": "MAVEN_REPOSITORY_SECRET", "registry_type": "maven_repository", "username": "monalisa", - "created_at": "2019-08-10T14:59:22Z", - "updated_at": "2020-01-10T14:59:22Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "visibility": "selected" } ] @@ -54,8 +53,8 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), Username: Ptr("monalisa"), - CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Visibility: Ptr(PrivateRegistryVisibilitySelected), }, }, @@ -110,8 +109,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T "username": "monalisa", "visibility": "selected", "selected_repository_ids": [1, 2, 3], - "created_at": "2019-08-10T14:59:22Z", - "updated_at": "2020-01-10T14:59:22Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -125,8 +124,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), Username: Ptr("monalisa"), - CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Visibility: Ptr(PrivateRegistryVisibilitySelected), SelectedRepositoryIDs: []int64{1, 2, 3}, } @@ -174,8 +173,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test "registry_type": "maven_repository", "visibility": "selected", "selected_repository_ids": [1, 2, 3], - "created_at": "2019-08-10T14:59:22Z", - "updated_at": "2020-01-10T14:59:22Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -188,8 +187,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test want := &PrivateRegistry{ Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), - CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Visibility: Ptr(PrivateRegistryVisibilitySelected), SelectedRepositoryIDs: []int64{1, 2, 3}, } @@ -250,8 +249,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t "name": "NPM_REGISTRY_SECRET", "registry_type": "npm_registry", "visibility": "private", - "created_at": "2019-08-10T14:59:22Z", - "updated_at": "2020-01-10T14:59:22Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -264,8 +263,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t want := &PrivateRegistry{ Name: Ptr("NPM_REGISTRY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeNpmRegistry), - CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Visibility: Ptr(PrivateRegistryVisibilityPrivate), } if diff := cmp.Diff(want, privateRegistry); diff != "" { @@ -325,8 +324,8 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) { "name": "MAVEN_REPOSITORY_SECRET", "registry_type": "maven_repository", "username": "monalisa", - "created_at": "2019-08-10T14:59:22Z", - "updated_at": "2020-01-10T14:59:22Z", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "visibility": "selected" }`) }) @@ -340,8 +339,8 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) { Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), Username: Ptr("monalisa"), - CreatedAt: &Timestamp{time.Date(2019, time.August, 10, 14, 59, 22, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2020, time.January, 10, 14, 59, 22, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, Visibility: Ptr(PrivateRegistryVisibilitySelected), } if diff := cmp.Diff(want, privateRegistry); diff != "" { diff --git a/github/projects_test.go b/github/projects_test.go index 296b4bf8dba..d786d279de2 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -11,7 +11,6 @@ import ( "fmt" "net/http" "testing" - "time" ) func TestProjectsService_ListOrganizationProjects(t *testing.T) { @@ -1094,7 +1093,7 @@ func TestProjectV2Item_UnmarshalJSON_Issue(t *testing.T) { }, }, }, - CreatedAt: &Timestamp{time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, } want := `{ @@ -1112,7 +1111,7 @@ func TestProjectV2Item_UnmarshalJSON_Issue(t *testing.T) { "name": "test-repo" } }, - "created_at": "2023-01-01T00:00:00Z" + "created_at": ` + referenceTimeStr + ` }` testJSONUnmarshalOnly(t, item, want) @@ -1143,7 +1142,7 @@ func TestProjectV2Item_UnmarshalJSON_PullRequest(t *testing.T) { }, }, }, - CreatedAt: &Timestamp{time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, } want := `{ @@ -1166,7 +1165,7 @@ func TestProjectV2Item_UnmarshalJSON_PullRequest(t *testing.T) { "sha": "ghi789" } }, - "created_at": "2023-01-02T00:00:00Z" + "created_at": ` + referenceTimeStr + ` }` testJSONUnmarshalOnly(t, item, want) @@ -1187,7 +1186,7 @@ func TestProjectV2Item_UnmarshalJSON_DraftIssue(t *testing.T) { Body: Ptr("Draft issue body content"), }, }, - CreatedAt: &Timestamp{time.Date(2023, 1, 3, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, } want := `{ @@ -1200,7 +1199,7 @@ func TestProjectV2Item_UnmarshalJSON_DraftIssue(t *testing.T) { "title": "Draft Issue Title", "body": "Draft issue body content" }, - "created_at": "2023-01-03T00:00:00Z" + "created_at": ` + referenceTimeStr + ` }` testJSONUnmarshalOnly(t, item, want) diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index cdb11eab420..1171b6bf2d7 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -10,7 +10,6 @@ import ( "net/http" "strings" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -26,7 +25,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { testFormValues(t, r, values{ "sort": "updated", "direction": "desc", - "since": "2002-02-10T15:30:00Z", + "since": referenceTimeRaw, "page": "2", }) fmt.Fprint(w, `[{"id":1}]`) @@ -35,7 +34,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { opt := &PullRequestListCommentsOptions{ Sort: "updated", Direction: "desc", - Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC), + Since: referenceTime, ListOptions: ListOptions{Page: 2}, } ctx := t.Context() diff --git a/github/rate_limit_test.go b/github/rate_limit_test.go index 5c90948ecae..8a6be8983a1 100644 --- a/github/rate_limit_test.go +++ b/github/rate_limit_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -43,18 +42,18 @@ func TestRateLimits(t *testing.T) { mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{"resources":{ - "core": {"limit":2,"remaining":1,"used":1,"reset":1372700873}, - "search": {"limit":3,"remaining":2,"used":1,"reset":1372700874}, - "graphql": {"limit":4,"remaining":3,"used":1,"reset":1372700875}, - "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":1372700876}, - "source_import": {"limit":6,"remaining":5,"used":1,"reset":1372700877}, - "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":1372700878}, - "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":1372700879}, - "scim": {"limit":9,"remaining":8,"used":1,"reset":1372700880}, - "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":1372700881}, - "code_search": {"limit":11,"remaining":10,"used":1,"reset":1372700882}, - "audit_log": {"limit": 12,"remaining":11,"used":1,"reset":1372700883}, - "dependency_sbom": {"limit": 100,"remaining":100,"used":0,"reset":1372700884} + "core": {"limit":2,"remaining":1,"used":1,"reset":`+referenceTimeStr+`}, + "search": {"limit":3,"remaining":2,"used":1,"reset":`+referenceTimeStr+`}, + "graphql": {"limit":4,"remaining":3,"used":1,"reset":`+referenceTimeStr+`}, + "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":`+referenceTimeStr+`}, + "source_import": {"limit":6,"remaining":5,"used":1,"reset":`+referenceTimeStr+`}, + "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":`+referenceTimeStr+`}, + "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":`+referenceTimeStr+`}, + "scim": {"limit":9,"remaining":8,"used":1,"reset":`+referenceTimeStr+`}, + "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":`+referenceTimeStr+`}, + "code_search": {"limit":11,"remaining":10,"used":1,"reset":`+referenceTimeStr+`}, + "audit_log": {"limit": 12,"remaining":11,"used":1,"reset":`+referenceTimeStr+`}, + "dependency_sbom": {"limit": 100,"remaining":100,"used":0,"reset":`+referenceTimeStr+`} }}`) }) @@ -69,73 +68,73 @@ func TestRateLimits(t *testing.T) { Limit: 2, Remaining: 1, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 53, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, Search: &Rate{ Limit: 3, Remaining: 2, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 54, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, GraphQL: &Rate{ Limit: 4, Remaining: 3, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 55, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, IntegrationManifest: &Rate{ Limit: 5, Remaining: 4, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 56, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, SourceImport: &Rate{ Limit: 6, Remaining: 5, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 57, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, CodeScanningUpload: &Rate{ Limit: 7, Remaining: 6, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 58, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, ActionsRunnerRegistration: &Rate{ Limit: 8, Remaining: 7, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 59, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, SCIM: &Rate{ Limit: 9, Remaining: 8, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 0, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, DependencySnapshots: &Rate{ Limit: 10, Remaining: 9, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 1, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, CodeSearch: &Rate{ Limit: 11, Remaining: 10, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 2, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, AuditLog: &Rate{ Limit: 12, Remaining: 11, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 3, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, DependencySBOM: &Rate{ Limit: 100, Remaining: 100, Used: 0, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 4, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, } if !cmp.Equal(rate, want) { @@ -223,22 +222,22 @@ func TestRateLimits_overQuota(t *testing.T) { Limit: 1, Remaining: 0, Used: 1, - Reset: Timestamp{time.Now().Add(time.Hour).Local()}, + Reset: referenceTimestamp, } mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{"resources":{ - "core": {"limit":2,"remaining":1,"used":1,"reset":1372700873}, - "search": {"limit":3,"remaining":2,"used":1,"reset":1372700874}, - "graphql": {"limit":4,"remaining":3,"used":1,"reset":1372700875}, - "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":1372700876}, - "source_import": {"limit":6,"remaining":5,"used":1,"reset":1372700877}, - "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":1372700878}, - "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":1372700879}, - "scim": {"limit":9,"remaining":8,"used":1,"reset":1372700880}, - "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":1372700881}, - "code_search": {"limit":11,"remaining":10,"used":1,"reset":1372700882}, - "audit_log": {"limit":12,"remaining":11,"used":1,"reset":1372700883}, - "dependency_sbom": {"limit":13,"remaining":12,"used":1,"reset":1372700884} + "core": {"limit":2,"remaining":1,"used":1,"reset":`+referenceTimeStr+`}, + "search": {"limit":3,"remaining":2,"used":1,"reset":`+referenceTimeStr+`}, + "graphql": {"limit":4,"remaining":3,"used":1,"reset":`+referenceTimeStr+`}, + "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":`+referenceTimeStr+`}, + "source_import": {"limit":6,"remaining":5,"used":1,"reset":`+referenceTimeStr+`}, + "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":`+referenceTimeStr+`}, + "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":`+referenceTimeStr+`}, + "scim": {"limit":9,"remaining":8,"used":1,"reset":`+referenceTimeStr+`}, + "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":`+referenceTimeStr+`}, + "code_search": {"limit":11,"remaining":10,"used":1,"reset":`+referenceTimeStr+`}, + "audit_log": {"limit":12,"remaining":11,"used":1,"reset":`+referenceTimeStr+`}, + "dependency_sbom": {"limit":13,"remaining":12,"used":1,"reset":`+referenceTimeStr+`} }}`) }) @@ -253,73 +252,73 @@ func TestRateLimits_overQuota(t *testing.T) { Limit: 2, Remaining: 1, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 53, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, Search: &Rate{ Limit: 3, Remaining: 2, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 54, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, GraphQL: &Rate{ Limit: 4, Remaining: 3, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 55, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, IntegrationManifest: &Rate{ Limit: 5, Remaining: 4, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 56, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, SourceImport: &Rate{ Limit: 6, Remaining: 5, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 57, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, CodeScanningUpload: &Rate{ Limit: 7, Remaining: 6, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 58, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, ActionsRunnerRegistration: &Rate{ Limit: 8, Remaining: 7, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 47, 59, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, SCIM: &Rate{ Limit: 9, Remaining: 8, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 0, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, DependencySnapshots: &Rate{ Limit: 10, Remaining: 9, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 1, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, CodeSearch: &Rate{ Limit: 11, Remaining: 10, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 2, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, AuditLog: &Rate{ Limit: 12, Remaining: 11, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 3, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, DependencySBOM: &Rate{ Limit: 13, Remaining: 12, Used: 1, - Reset: Timestamp{time.Date(2013, time.July, 1, 17, 48, 4, 0, time.UTC).Local()}, + Reset: referenceTimestamp, }, } if !cmp.Equal(rate, want) { diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index a6b64b3a7f3..1133ecd5e93 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -11,7 +11,6 @@ import ( "net/url" "strings" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -28,8 +27,8 @@ func TestRepositoriesService_ListCommits(t *testing.T) { "sha": "s", "path": "p", "author": "a", - "since": "2013-08-01T00:00:00Z", - "until": "2013-09-03T00:00:00Z", + "since": referenceTimeRaw, + "until": referenceTimeRaw, }) fmt.Fprint(w, `[{"sha": "s"}]`) }) @@ -38,8 +37,8 @@ func TestRepositoriesService_ListCommits(t *testing.T) { SHA: "s", Path: "p", Author: "a", - Since: time.Date(2013, time.August, 1, 0, 0, 0, 0, time.UTC), - Until: time.Date(2013, time.September, 3, 0, 0, 0, 0, time.UTC), + Since: referenceTime, + Until: referenceTime, } ctx := t.Context() commits, _, err := client.Repositories.ListCommits(ctx, "o", "r", opt) diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index 87a10cf1492..19705d5ee6c 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -60,7 +59,7 @@ func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { "html_url": "https://github.com/octocat/Hello-World/blob/master/README.md" } }, - "updated_at": "2017-02-28T00:00:00Z", + "updated_at": `+referenceTimeStr+`, "content_reports_enabled": true }`) }) @@ -71,11 +70,10 @@ func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { t.Errorf("Repositories.GetCommunityHealthMetrics returned error: %v", err) } - updatedAt := time.Date(2017, time.February, 28, 0, 0, 0, 0, time.UTC) want := &CommunityHealthMetrics{ HealthPercentage: Ptr(100), Description: Ptr("My first repository on GitHub!"), - UpdatedAt: &Timestamp{updatedAt}, + UpdatedAt: &referenceTimestamp, ContentReportsEnabled: Ptr(true), Files: &CommunityHealthFiles{ CodeOfConduct: &Metric{ diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 3968f591e5c..77eb5e23d2b 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -32,7 +31,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { "total": 135, "weeks": [ { - "w": 1367712000, + "w": `+referenceUnixTimeStr+`, "a": 6898, "d": 77, "c": 10 @@ -58,7 +57,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { Total: Ptr(135), Weeks: []*WeeklyStats{ { - Week: &Timestamp{time.Date(2013, time.May, 5, 0, 0, 0, 0, time.UTC).Local()}, + Week: &referenceTimestamp, Additions: Ptr(6898), Deletions: Ptr(77), Commits: Ptr(10), @@ -98,7 +97,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { { "days": [0, 3, 26, 20, 39, 1, 0], "total": 89, - "week": 1336280400 + "week": `+referenceUnixTimeStr+` } ] `) @@ -114,7 +113,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { { Days: []int{0, 3, 26, 20, 39, 1, 0}, Total: Ptr(89), - Week: &Timestamp{time.Date(2012, time.May, 6, 5, 0, 0, 0, time.UTC).Local()}, + Week: &referenceTimestamp, }, } @@ -144,7 +143,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { mux.HandleFunc("/repos/o/r/stats/code_frequency", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `[[1302998400, 1124, -435]]`) + fmt.Fprint(w, `[[`+referenceUnixTimeStr+`, 1124, -435]]`) }) ctx := t.Context() @@ -154,7 +153,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { } want := []*WeeklyStats{{ - Week: &Timestamp{time.Date(2011, time.April, 17, 0, 0, 0, 0, time.UTC).Local()}, + Week: &referenceTimestamp, Additions: Ptr(1124), Deletions: Ptr(-435), }} diff --git a/github/repos_test.go b/github/repos_test.go index bc8211fd15c..2951b5634eb 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -13,7 +13,6 @@ import ( "net/url" "strings" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -4279,7 +4278,7 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { "before": "abc123def456", "after": "def456ghi789", "ref": "refs/heads/main", - "timestamp": "2023-01-01T12:00:00Z", + "timestamp": `+referenceTimeStr+`, "activity_type": "push", "actor": { "login": "testuser1", @@ -4309,7 +4308,7 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { "before": "def456ghi789", "after": "ghi789jkl012", "ref": "refs/heads/feature", - "timestamp": "2023-01-01T11:30:00Z", + "timestamp": `+referenceTimeStr+`, "activity_type": "branch_deletion", "actor": { "login": "testuser2", @@ -4350,7 +4349,7 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { Before: "abc123def456", After: "def456ghi789", Ref: "refs/heads/main", - Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)}, + Timestamp: &referenceTimestamp, ActivityType: "push", Actor: &RepositoryActor{ Login: Ptr("testuser1"), @@ -4380,7 +4379,7 @@ func TestRepositoriesService_ListRepositoryActivities(t *testing.T) { Before: "def456ghi789", After: "ghi789jkl012", Ref: "refs/heads/feature", - Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 11, 30, 0, 0, time.UTC)}, + Timestamp: &referenceTimestamp, ActivityType: "branch_deletion", Actor: &RepositoryActor{ Login: Ptr("testuser2"), @@ -4433,8 +4432,8 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) testMethod(t, r, "GET") testFormValues(t, r, values{ "direction": "desc", - "before": "2023-01-01T12:00:00Z", - "after": "2023-01-01T11:30:00Z", + "before": referenceTimeStr, + "after": referenceTimeStr, "ref": "refs/heads/main", "actor": "testuser1", "time_period": "day", @@ -4448,7 +4447,7 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) "before": "abc123def456", "after": "def456ghi789", "ref": "refs/heads/main", - "timestamp": "2023-01-01T12:00:00Z", + "timestamp": `+referenceTimeStr+`, "activity_type": "push", "actor": { "login": "testuser1", @@ -4477,8 +4476,8 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) opts := &ListRepositoryActivityOptions{ Direction: "desc", - Before: "2023-01-01T12:00:00Z", - After: "2023-01-01T11:30:00Z", + Before: referenceTimeStr, + After: referenceTimeStr, Ref: "refs/heads/main", Actor: "testuser1", TimePeriod: "day", @@ -4498,7 +4497,7 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) Before: "abc123def456", After: "def456ghi789", Ref: "refs/heads/main", - Timestamp: &Timestamp{Time: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)}, + Timestamp: &referenceTimestamp, ActivityType: "push", Actor: &RepositoryActor{ Login: Ptr("testuser1"), diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index d01d5b87320..3578739fbe3 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -109,7 +108,7 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { fmt.Fprint(w, `{"count": 7, "uniques": 6, "views": [{ - "timestamp": "2016-05-31T16:00:00.000Z", + "timestamp": `+referenceTimeStr+`, "count": 7, "uniques": 6 }]}`) @@ -123,7 +122,7 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { want := &TrafficViews{ Views: []*TrafficData{{ - Timestamp: &Timestamp{time.Date(2016, time.May, 31, 16, 0, 0, 0, time.UTC)}, + Timestamp: &referenceTimestamp, Count: Ptr(7), Uniques: Ptr(6), }}, @@ -159,7 +158,7 @@ func TestRepositoriesService_ListTrafficClones(t *testing.T) { fmt.Fprint(w, `{"count": 7, "uniques": 6, "clones": [{ - "timestamp": "2016-05-31T16:00:00.00Z", + "timestamp": `+referenceTimeStr+`, "count": 7, "uniques": 6 }]}`) @@ -173,7 +172,7 @@ func TestRepositoriesService_ListTrafficClones(t *testing.T) { want := &TrafficClones{ Clones: []*TrafficData{{ - Timestamp: &Timestamp{time.Date(2016, time.May, 31, 16, 0, 0, 0, time.UTC)}, + Timestamp: &referenceTimestamp, Count: Ptr(7), Uniques: Ptr(6), }}, diff --git a/github/scim_test.go b/github/scim_test.go index 115bc896092..514151eb610 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -53,8 +52,8 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { "active": true, "meta": { "resourceType": "User", - "created": "2018-02-13T15:05:24.000-00:00", - "lastModified": "2018-02-13T15:05:24.000-00:00", + "created": ` + referenceTimeStr + `, + "lastModified": ` + referenceTimeStr + `, "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75" } } @@ -73,7 +72,7 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { t.Errorf("SCIM.ListSCIMProvisionedIdentities returned error: %v", err) } - date := Timestamp{time.Date(2018, time.February, 13, 15, 5, 24, 0, time.UTC)} + date := referenceTimestamp want := SCIMProvisionedIdentities{ Schemas: []string{"urn:ietf:params:scim:api:messages:2.0:ListResponse"}, TotalResults: Ptr(1), @@ -209,8 +208,8 @@ func TestSCIMService_GetSCIMProvisioningInfoForUser(t *testing.T) { "active": true, "meta": { "resourceType": "User", - "created": "2017-03-09T16:11:13-00:00", - "lastModified": "2017-03-09T16:11:13-00:00", + "created": ` + referenceTimeStr + `, + "lastModified": ` + referenceTimeStr + `, "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32" } }`)) @@ -222,7 +221,7 @@ func TestSCIMService_GetSCIMProvisioningInfoForUser(t *testing.T) { t.Errorf("SCIM.GetSCIMProvisioningInfoForUser returned error: %v", err) } - date := Timestamp{time.Date(2017, time.March, 9, 16, 11, 13, 0, time.UTC)} + date := referenceTimestamp want := SCIMUserAttributes{ ID: Ptr("edefdfedf-050c-11e7-8d32"), Meta: &SCIMMeta{ diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 651d1f5ab0a..1b77a4202e7 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -24,7 +23,7 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": "1996-06-20T00:00:00Z", + "created_at": `+referenceTimeStr+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -50,11 +49,10 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForEnterprise returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &date, + CreatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -99,7 +97,7 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": "1996-06-20T00:00:00Z", + "created_at": `+referenceTimeStr+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -120,11 +118,10 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &date, + CreatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -164,7 +161,7 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": "1996-06-20T00:00:00Z", + "created_at": `+referenceTimeStr+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -187,11 +184,10 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForOrg returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &date, + CreatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -231,7 +227,7 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": "1996-06-20T00:00:00Z", + "created_at": `+referenceTimeStr+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -252,11 +248,10 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) { t.Errorf("SecretScanning.ListAlertsForRepo returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &date, + CreatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -295,7 +290,7 @@ func TestSecretScanningService_GetAlert(t *testing.T) { fmt.Fprint(w, `{ "number": 1, - "created_at": "1996-06-20T00:00:00Z", + "created_at": `+referenceTimeStr+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -315,10 +310,9 @@ func TestSecretScanningService_GetAlert(t *testing.T) { t.Errorf("SecretScanning.GetAlert returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := &SecretScanningAlert{ Number: Ptr(1), - CreatedAt: &date, + CreatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -358,14 +352,14 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { testJSONBody(t, r, opts) fmt.Fprint(w, `{ "number": 1, - "created_at": "1996-06-20T00:00:00Z", + "created_at": `+referenceTimeStr+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", "state": "resolved", "resolution": "used_in_tests", "resolution_comment": "resolution comment", - "resolved_at": "1996-06-20T00:00:00Z", + "resolved_at": `+referenceTimeStr+`, "resolved_by": null, "secret_type": "mailchimp_api_key", "secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2" @@ -378,17 +372,16 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { t.Errorf("SecretScanning.UpdateAlert returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} want := &SecretScanningAlert{ Number: Ptr(1), - CreatedAt: &date, + CreatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), State: Ptr("resolved"), Resolution: Ptr("used_in_tests"), ResolutionComment: Ptr("resolution comment"), - ResolvedAt: &date, + ResolvedAt: &referenceTimestamp, ResolvedBy: nil, SecretType: Ptr("mailchimp_api_key"), Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), @@ -490,7 +483,7 @@ func TestSecretScanningService_CreatePushProtectionBypass(t *testing.T) { testJSONBody(t, r, opts) fmt.Fprint(w, `{ "reason": "valid reason", - "expire_at": "2018-01-01T00:00:00Z", + "expire_at": `+referenceTimeStr+`, "token_type": "github_token" }`) }) @@ -502,10 +495,9 @@ func TestSecretScanningService_CreatePushProtectionBypass(t *testing.T) { t.Errorf("SecretScanning.CreatePushProtectionBypass returned error: %v", err) } - expireTime := Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)} want := &PushProtectionBypass{ Reason: "valid reason", - ExpireAt: &expireTime, + ExpireAt: &referenceTimestamp, TokenType: "github_token", } @@ -537,8 +529,8 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { { "type": "incremental", "status": "success", - "completed_at": "2025-07-29T10:00:00Z", - "started_at": "2025-07-29T09:55:00Z" + "completed_at": `+referenceTimeStr+`, + "started_at": `+referenceTimeStr+` } ], "backfill_scans": [], @@ -548,7 +540,7 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { "type": "custom_backfill", "status": "in_progress", "completed_at": null, - "started_at": "2025-07-29T09:00:00Z", + "started_at": `+referenceTimeStr+`, "pattern_slug": "my-custom-pattern", "pattern_scope": "organization" } @@ -563,19 +555,15 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { t.Errorf("SecretScanning.GetScanHistory returned error: %v", err) } - incrementalScanStartAt := Timestamp{time.Date(2025, time.July, 29, 9, 55, 0, 0, time.UTC)} - incrementalScancompleteAt := Timestamp{time.Date(2025, time.July, 29, 10, 0, 0, 0, time.UTC)} - customPatternBackfillScanStartedAt := Timestamp{time.Date(2025, time.July, 29, 9, 0, 0, 0, time.UTC)} - want := &SecretScanningScanHistory{ IncrementalScans: []*SecretsScan{ - {Type: "incremental", Status: "success", CompletedAt: &incrementalScancompleteAt, StartedAt: &incrementalScanStartAt}, + {Type: "incremental", Status: "success", CompletedAt: &referenceTimestamp, StartedAt: &referenceTimestamp}, }, BackfillScans: []*SecretsScan{}, PatternUpdateScans: []*SecretsScan{}, CustomPatternBackfillScans: []*CustomPatternBackfillScan{ { - SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: &customPatternBackfillScanStartedAt}, + SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: &referenceTimestamp}, PatternSlug: Ptr("my-custom-pattern"), PatternScope: Ptr("organization"), }, diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index 0890763c25b..5e435421f22 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -87,9 +86,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork(t *testing.T) { "name": "repo-ghsa-xxxx-xxxx-xxxx", "full_name": "owner/repo-ghsa-xxxx-xxxx-xxxx", "default_branch": "master", - "created_at": "2023-12-08T17:22:41Z", - "pushed_at": "2023-12-03T11:27:08Z", - "updated_at": "2023-12-08T17:22:42Z", + "created_at": `+referenceTimeStr+`, + "pushed_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "html_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx", "clone_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", "git_url": "git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", @@ -196,9 +195,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork(t *testing.T) { Name: Ptr("repo-ghsa-xxxx-xxxx-xxxx"), FullName: Ptr("owner/repo-ghsa-xxxx-xxxx-xxxx"), DefaultBranch: Ptr("master"), - CreatedAt: &Timestamp{time.Date(2023, time.December, 8, 17, 22, 41, 0, time.UTC)}, - PushedAt: &Timestamp{time.Date(2023, time.December, 3, 11, 27, 8, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2023, time.December, 8, 17, 22, 42, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + PushedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, HTMLURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), CloneURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), GitURL: Ptr("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), @@ -323,9 +322,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork_deferred(t *testin "name": "repo-ghsa-xxxx-xxxx-xxxx", "full_name": "owner/repo-ghsa-xxxx-xxxx-xxxx", "default_branch": "master", - "created_at": "2023-12-08T17:22:41Z", - "pushed_at": "2023-12-03T11:27:08Z", - "updated_at": "2023-12-08T17:22:42Z", + "created_at": `+referenceTimeStr+`, + "pushed_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, "html_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx", "clone_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", "git_url": "git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", @@ -432,9 +431,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork_deferred(t *testin Name: Ptr("repo-ghsa-xxxx-xxxx-xxxx"), FullName: Ptr("owner/repo-ghsa-xxxx-xxxx-xxxx"), DefaultBranch: Ptr("master"), - CreatedAt: &Timestamp{time.Date(2023, time.December, 8, 17, 22, 41, 0, time.UTC)}, - PushedAt: &Timestamp{time.Date(2023, time.December, 3, 11, 27, 8, 0, time.UTC)}, - UpdatedAt: &Timestamp{time.Date(2023, time.December, 8, 17, 22, 42, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, + PushedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, HTMLURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), CloneURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), GitURL: Ptr("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), @@ -774,10 +773,10 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { } ], "references": ["https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"], - "published_at": "1996-06-20T00:00:00Z", - "updated_at": "1996-06-20T00:00:00Z", - "github_reviewed_at": "1996-06-20T00:00:00Z", - "nvd_published_at": "1996-06-20T00:00:00Z", + "published_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, + "github_reviewed_at": `+referenceTimeStr+`, + "nvd_published_at": `+referenceTimeStr+`, "withdrawn_at": null, "vulnerabilities": [ { @@ -837,7 +836,7 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { t.Errorf("SecurityAdvisories.ListGlobalSecurityAdvisories returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} + date := referenceTimestamp want := []*GlobalSecurityAdvisory{ { ID: Ptr(int64(1)), @@ -959,10 +958,10 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { } ], "references": ["https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"], - "published_at": "1996-06-20T00:00:00Z", - "updated_at": "1996-06-20T00:00:00Z", - "github_reviewed_at": "1996-06-20T00:00:00Z", - "nvd_published_at": "1996-06-20T00:00:00Z", + "published_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+`, + "github_reviewed_at": `+referenceTimeStr+`, + "nvd_published_at": `+referenceTimeStr+`, "withdrawn_at": null, "vulnerabilities": [ { @@ -1019,7 +1018,7 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { t.Errorf("SecurityAdvisories.GetGlobalSecurityAdvisories returned error: %v", err) } - date := Timestamp{time.Date(1996, time.June, 20, 0, 0, 0, 0, time.UTC)} + date := referenceTimestamp want := &GlobalSecurityAdvisory{ ID: Ptr(int64(1)), SecurityAdvisory: SecurityAdvisory{ diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index 5863fe0a49c..b68712d1866 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -66,13 +65,13 @@ func TestTeamsService_ListComments(t *testing.T) { "body": "comment", "body_html": "

comment

", "body_version": "version", - "created_at": "2018-01-01T00:00:00Z", + "created_at": `+referenceTimeStr+`, "last_edited_at": null, "discussion_url": "https://api.github.com/teams/2/discussions/3", "html_url": "https://github.com/orgs/1/teams/2/discussions/3/comments/4", "node_id": "node", "number": 4, - "updated_at": "2018-01-01T00:00:00Z", + "updated_at": `+referenceTimeStr+`, "url": "https://api.github.com/teams/2/discussions/3/comments/4" } ]`) @@ -102,13 +101,13 @@ func TestTeamsService_ListComments(t *testing.T) { Body: Ptr("comment"), BodyHTML: Ptr("

comment

"), BodyVersion: Ptr("version"), - CreatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, LastEditedAt: nil, DiscussionURL: Ptr("https://api.github.com/teams/2/discussions/3"), HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3/comments/4"), NodeID: Ptr("node"), Number: Ptr(4), - UpdatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + UpdatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/teams/2/discussions/3/comments/4"), }, } diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index 70d5898bb7c..ce25c7460ec 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -9,7 +9,6 @@ import ( "fmt" "net/http" "testing" - "time" "github.com/google/go-cmp/cmp" ) @@ -51,7 +50,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { "body_version": "version", "comments_count": 1, "comments_url": "https://api.github.com/teams/2/discussions/3/comments", - "created_at": "2018-01-01T00:00:00Z", + "created_at": `+referenceTimeStr+`, "last_edited_at": null, "html_url": "https://github.com/orgs/1/teams/2/discussions/3", "node_id": "node", @@ -60,7 +59,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { "private": false, "team_url": "https://api.github.com/teams/2", "title": "test", - "updated_at": "2018-01-01T00:00:00Z", + "updated_at": `+referenceTimeStr+`, "url": "https://api.github.com/teams/2/discussions/3" } ]`) @@ -97,7 +96,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { BodyVersion: Ptr("version"), CommentsCount: Ptr(1), CommentsURL: Ptr("https://api.github.com/teams/2/discussions/3/comments"), - CreatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, LastEditedAt: nil, HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3"), NodeID: Ptr("node"), @@ -106,7 +105,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { Private: Ptr(false), TeamURL: Ptr("https://api.github.com/teams/2"), Title: Ptr("test"), - UpdatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + UpdatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/teams/2/discussions/3"), }, } @@ -166,7 +165,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { "body_version": "version", "comments_count": 1, "comments_url": "https://api.github.com/teams/2/discussions/3/comments", - "created_at": "2018-01-01T00:00:00Z", + "created_at": `+referenceTimeStr+`, "last_edited_at": null, "html_url": "https://github.com/orgs/1/teams/2/discussions/3", "node_id": "node", @@ -175,7 +174,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { "private": false, "team_url": "https://api.github.com/teams/2", "title": "test", - "updated_at": "2018-01-01T00:00:00Z", + "updated_at": `+referenceTimeStr+`, "url": "https://api.github.com/teams/2/discussions/3" } ]`) @@ -212,7 +211,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { BodyVersion: Ptr("version"), CommentsCount: Ptr(1), CommentsURL: Ptr("https://api.github.com/teams/2/discussions/3/comments"), - CreatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + CreatedAt: &referenceTimestamp, LastEditedAt: nil, HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3"), NodeID: Ptr("node"), @@ -221,7 +220,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { Private: Ptr(false), TeamURL: Ptr("https://api.github.com/teams/2"), Title: Ptr("test"), - UpdatedAt: &Timestamp{time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC)}, + UpdatedAt: &referenceTimestamp, URL: Ptr("https://api.github.com/teams/2/discussions/3"), }, } diff --git a/github/timestamp_test.go b/github/timestamp_test.go index 65e5ed88e50..2ea2164b16b 100644 --- a/github/timestamp_test.go +++ b/github/timestamp_test.go @@ -13,6 +13,7 @@ import ( const ( emptyTimeStr = `"0001-01-01T00:00:00Z"` + referenceTimeRaw = "2006-01-02T15:04:05Z" referenceTimeStr = `"2006-01-02T15:04:05Z"` referenceTimeStrFractional = `"2006-01-02T15:04:05.000Z"` // This format was returned by the Projects API before October 1, 2017. referenceUnixTimeStr = `1136214245` @@ -20,8 +21,9 @@ const ( ) var ( - referenceTime = time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC) - unixOrigin = time.Unix(0, 0).In(time.UTC) + referenceTime = time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC) + referenceTimestamp = Timestamp{referenceTime} + unixOrigin = time.Unix(0, 0).In(time.UTC) ) func TestTimestamp_Marshal(t *testing.T) { From 0c9f7067393d0e92f9d8c2d5cd527d42967541d7 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:21:15 -0400 Subject: [PATCH 02/34] Cleanup Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_hosted_runners_test.go | 18 ++++++---------- github/activity_notifications_test.go | 30 ++++++++++----------------- github/code_scanning_test.go | 19 +++++++---------- github/scim_test.go | 10 ++++----- github/security_advisories_test.go | 18 +++++++--------- 5 files changed, 36 insertions(+), 59 deletions(-) diff --git a/github/actions_hosted_runners_test.go b/github/actions_hosted_runners_test.go index 1afa8e0b533..b4cc96a61ba 100644 --- a/github/actions_hosted_runners_test.go +++ b/github/actions_hosted_runners_test.go @@ -80,8 +80,6 @@ func TestActionsService_ListHostedRunners(t *testing.T) { t.Errorf("Actions.ListHostedRunners returned error: %v", err) } - lastActiveOn := referenceTimestamp - want := &HostedRunners{ TotalCount: 2, Runners: []*HostedRunner{ @@ -110,7 +108,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, }, { ID: Ptr(int64(7)), @@ -131,7 +129,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) { MaximumRunners: Ptr(int64(20)), PublicIPEnabled: Ptr(false), PublicIPs: []*HostedRunnerPublicIP{}, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, }, }, } @@ -209,7 +207,6 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { t.Errorf("Actions.CreateHostedRunner returned error: %v", err) } - lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -235,7 +232,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -625,7 +622,6 @@ func TestActionsService_GetHostedRunner(t *testing.T) { t.Errorf("Actions.GetHostedRunner returned error: %v", err) } - lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -651,7 +647,7 @@ func TestActionsService_GetHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -721,7 +717,6 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { t.Errorf("Actions.UpdateHostedRunner returned error: %v", err) } - lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -747,7 +742,7 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { @@ -810,7 +805,6 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) { t.Errorf("Actions.DeleteHostedRunner returned error: %v", err) } - lastActiveOn := referenceTimestamp want := &HostedRunner{ ID: Ptr(int64(5)), Name: Ptr("My hosted ubuntu runner"), @@ -836,7 +830,7 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) { Length: 31, }, }, - LastActiveOn: &lastActiveOn, + LastActiveOn: &referenceTimestamp, } if !cmp.Equal(hostedRunner, want) { diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index fa64d1cad80..009ab08f9ef 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -95,13 +95,11 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := referenceTimestamp - mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") want := markReadOptions{ - LastReadAt: input, + LastReadAt: referenceTimestamp, } testJSONBody(t, r, want) @@ -109,14 +107,14 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { }) ctx := t.Context() - _, err := client.Activity.MarkNotificationsRead(ctx, input) + _, err := client.Activity.MarkNotificationsRead(ctx, referenceTimestamp) if err != nil { t.Errorf("Activity.MarkNotificationsRead returned error: %v", err) } const methodName = "MarkNotificationsRead" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Activity.MarkNotificationsRead(ctx, input) + return client.Activity.MarkNotificationsRead(ctx, referenceTimestamp) }) } @@ -124,13 +122,11 @@ func TestActivityService_MarkNotificationsRead_EmptyLastReadAt(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := referenceTimestamp - mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") want := markReadOptions{ - LastReadAt: input, + LastReadAt: referenceTimestamp, } testJSONBody(t, r, want) @@ -138,7 +134,7 @@ func TestActivityService_MarkNotificationsRead_EmptyLastReadAt(t *testing.T) { }) ctx := t.Context() - _, err := client.Activity.MarkNotificationsRead(ctx, input) + _, err := client.Activity.MarkNotificationsRead(ctx, referenceTimestamp) if err != nil { t.Errorf("Activity.MarkNotificationsRead returned error: %v", err) } @@ -148,32 +144,30 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := referenceTimestamp - mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") want := markReadOptions{ - LastReadAt: input, + LastReadAt: referenceTimestamp, } testJSONBody(t, r, want) w.WriteHeader(http.StatusResetContent) }) ctx := t.Context() - _, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", input) + _, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", referenceTimestamp) if err != nil { t.Errorf("Activity.MarkRepositoryNotificationsRead returned error: %v", err) } const methodName = "MarkRepositoryNotificationsRead" testBadOptions(t, methodName, func() (err error) { - _, err = client.Activity.MarkRepositoryNotificationsRead(ctx, "\n", "\n", input) + _, err = client.Activity.MarkRepositoryNotificationsRead(ctx, "\n", "\n", referenceTimestamp) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - return client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", input) + return client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", referenceTimestamp) }) } @@ -181,13 +175,11 @@ func TestActivityService_MarkRepositoryNotificationsRead_EmptyLastReadAt(t *test t.Parallel() client, mux, _ := setup(t) - input := referenceTimestamp - mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") want := markReadOptions{ - LastReadAt: input, + LastReadAt: referenceTimestamp, } testJSONBody(t, r, want) @@ -195,7 +187,7 @@ func TestActivityService_MarkRepositoryNotificationsRead_EmptyLastReadAt(t *test }) ctx := t.Context() - _, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", input) + _, err := client.Activity.MarkRepositoryNotificationsRead(ctx, "o", "r", referenceTimestamp) if err != nil { t.Errorf("Activity.MarkRepositoryNotificationsRead returned error: %v", err) } diff --git a/github/code_scanning_test.go b/github/code_scanning_test.go index 3f6c6a1bad2..713cd841c68 100644 --- a/github/code_scanning_test.go +++ b/github/code_scanning_test.go @@ -239,7 +239,6 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForOrg returned error: %v", err) } - date := referenceTimestamp want := []*Alert{ { Repository: &Repository{ @@ -259,7 +258,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: Ptr("open"), ClosedBy: nil, ClosedAt: nil, @@ -295,7 +294,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: Ptr("open"), ClosedBy: nil, ClosedAt: nil, @@ -401,7 +400,6 @@ func TestCodeScanningService_ListAlertsForOrgLisCursorOptions(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForOrg returned error: %v", err) } - date := referenceTimestamp want := []*Alert{ { Repository: &Repository{ @@ -421,7 +419,7 @@ func TestCodeScanningService_ListAlertsForOrgLisCursorOptions(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: Ptr("open"), ClosedBy: nil, ClosedAt: nil, @@ -564,7 +562,6 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { t.Errorf("CodeScanning.ListAlertsForRepo returned error: %v", err) } - date := referenceTimestamp want := []*Alert{ { RuleID: Ptr("js/trivial-conditional"), @@ -579,7 +576,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: Ptr("open"), ClosedBy: nil, ClosedAt: nil, @@ -615,7 +612,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: Ptr("open"), ClosedBy: nil, ClosedAt: nil, @@ -718,7 +715,6 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { t.Errorf("CodeScanning.UpdateAlert returned error: %v", err) } - date := referenceTimestamp want := &Alert{ RuleID: Ptr("js/useless-expression"), RuleSeverity: Ptr("warning"), @@ -732,7 +728,7 @@ func TestCodeScanningService_UpdateAlert(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: state, DismissedReason: dismissedReason, DismissedComment: dismissedComment, @@ -911,7 +907,6 @@ func TestCodeScanningService_GetAlert(t *testing.T) { t.Errorf("CodeScanning.GetAlert returned error: %v", err) } - date := referenceTimestamp want := &Alert{ RuleID: Ptr("js/useless-expression"), RuleSeverity: Ptr("warning"), @@ -925,7 +920,7 @@ func TestCodeScanningService_GetAlert(t *testing.T) { FullDescription: Ptr("Expression has no effect"), Help: Ptr("Expression has no effect"), }, - CreatedAt: &date, + CreatedAt: &referenceTimestamp, State: Ptr("open"), ClosedBy: nil, ClosedAt: nil, diff --git a/github/scim_test.go b/github/scim_test.go index 514151eb610..6ca1d323653 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -72,7 +72,6 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { t.Errorf("SCIM.ListSCIMProvisionedIdentities returned error: %v", err) } - date := referenceTimestamp want := SCIMProvisionedIdentities{ Schemas: []string{"urn:ietf:params:scim:api:messages:2.0:ListResponse"}, TotalResults: Ptr(1), @@ -83,8 +82,8 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { ID: Ptr("5fc0c238-1112-11e8-8e45-920c87bdbd75"), Meta: &SCIMMeta{ ResourceType: Ptr("User"), - Created: &date, - LastModified: &date, + Created: &referenceTimestamp, + LastModified: &referenceTimestamp, Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75"), }, UserName: "octocat@github.com", @@ -221,13 +220,12 @@ func TestSCIMService_GetSCIMProvisioningInfoForUser(t *testing.T) { t.Errorf("SCIM.GetSCIMProvisioningInfoForUser returned error: %v", err) } - date := referenceTimestamp want := SCIMUserAttributes{ ID: Ptr("edefdfedf-050c-11e7-8d32"), Meta: &SCIMMeta{ ResourceType: Ptr("User"), - Created: &date, - LastModified: &date, + Created: &referenceTimestamp, + LastModified: &referenceTimestamp, Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"), }, UserName: "mona.octocat@okta.example.com", diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index 5e435421f22..7332e3965fa 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -836,7 +836,6 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { t.Errorf("SecurityAdvisories.ListGlobalSecurityAdvisories returned error: %v", err) } - date := referenceTimestamp want := []*GlobalSecurityAdvisory{ { ID: Ptr(int64(1)), @@ -858,8 +857,8 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { Value: Ptr("CVE-xoxo-1234"), }, }, - PublishedAt: &date, - UpdatedAt: &date, + PublishedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, WithdrawnAt: nil, CVSS: &AdvisoryCVSS{ VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), @@ -887,8 +886,8 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { RepositoryAdvisoryURL: Ptr("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), Type: Ptr("reviewed"), SourceCodeLocation: Ptr("https://github.com/project/a-package"), - GithubReviewedAt: &date, - NVDPublishedAt: &date, + GithubReviewedAt: &referenceTimestamp, + NVDPublishedAt: &referenceTimestamp, Credits: []*Credit{ { User: &User{ @@ -1018,7 +1017,6 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { t.Errorf("SecurityAdvisories.GetGlobalSecurityAdvisories returned error: %v", err) } - date := referenceTimestamp want := &GlobalSecurityAdvisory{ ID: Ptr(int64(1)), SecurityAdvisory: SecurityAdvisory{ @@ -1039,8 +1037,8 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { Value: Ptr("CVE-xoxo-1234"), }, }, - PublishedAt: &date, - UpdatedAt: &date, + PublishedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, WithdrawnAt: nil, CVSS: &AdvisoryCVSS{ VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), @@ -1057,8 +1055,8 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { Type: Ptr("reviewed"), SourceCodeLocation: Ptr("https://github.com/project/a-package"), References: []string{"https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"}, - GithubReviewedAt: &date, - NVDPublishedAt: &date, + GithubReviewedAt: &referenceTimestamp, + NVDPublishedAt: &referenceTimestamp, Vulnerabilities: []*GlobalSecurityVulnerability{ { From 611d23b7c407ab5d6ebff69c32e28202bb2117b2 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:22:32 -0400 Subject: [PATCH 03/34] Cleanup Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/copilot_test.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index c5e1b3ebbf1..81ae69a3efd 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -499,10 +499,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Parent: nil, }, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: nil, - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -527,10 +527,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { SiteAdmin: Ptr(false), }, AssigningTeam: nil, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -540,10 +540,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Type: Ptr("Team"), }, AssigningTeam: nil, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -553,10 +553,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Type: Ptr("Organization"), }, AssigningTeam: nil, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, }, @@ -713,10 +713,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), Parent: nil, }, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: nil, - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), PlanType: Ptr("business"), }, @@ -742,10 +742,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { SiteAdmin: Ptr(false), }, AssigningTeam: nil, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), PlanType: nil, }, @@ -1137,10 +1137,10 @@ func TestCopilotService_GetSeatDetails(t *testing.T) { RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), Parent: nil, }, - CreatedAt: Ptr(referenceTimestamp), - UpdatedAt: Ptr(referenceTimestamp), + CreatedAt: &referenceTimestamp, + UpdatedAt: &referenceTimestamp, PendingCancellationDate: nil, - LastActivityAt: Ptr(referenceTimestamp), + LastActivityAt: &referenceTimestamp, LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), } From 0a0aa5c972efe17fe0716b6dd9e6b63992e0976d Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 09:39:46 -0400 Subject: [PATCH 04/34] Fix rate_limit_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/rate_limit_test.go | 99 ++++++++++++++++++++------------------- github/timestamp_test.go | 1 + 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/github/rate_limit_test.go b/github/rate_limit_test.go index 8a6be8983a1..a8c3c8dd2c5 100644 --- a/github/rate_limit_test.go +++ b/github/rate_limit_test.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "testing" + "time" "github.com/google/go-cmp/cmp" ) @@ -42,18 +43,18 @@ func TestRateLimits(t *testing.T) { mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{"resources":{ - "core": {"limit":2,"remaining":1,"used":1,"reset":`+referenceTimeStr+`}, - "search": {"limit":3,"remaining":2,"used":1,"reset":`+referenceTimeStr+`}, - "graphql": {"limit":4,"remaining":3,"used":1,"reset":`+referenceTimeStr+`}, - "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":`+referenceTimeStr+`}, - "source_import": {"limit":6,"remaining":5,"used":1,"reset":`+referenceTimeStr+`}, - "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":`+referenceTimeStr+`}, - "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":`+referenceTimeStr+`}, - "scim": {"limit":9,"remaining":8,"used":1,"reset":`+referenceTimeStr+`}, - "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":`+referenceTimeStr+`}, - "code_search": {"limit":11,"remaining":10,"used":1,"reset":`+referenceTimeStr+`}, - "audit_log": {"limit": 12,"remaining":11,"used":1,"reset":`+referenceTimeStr+`}, - "dependency_sbom": {"limit": 100,"remaining":100,"used":0,"reset":`+referenceTimeStr+`} + "core": {"limit":2,"remaining":1,"used":1,"reset":1372700873}, + "search": {"limit":3,"remaining":2,"used":1,"reset":1372700874}, + "graphql": {"limit":4,"remaining":3,"used":1,"reset":1372700875}, + "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":1372700876}, + "source_import": {"limit":6,"remaining":5,"used":1,"reset":1372700877}, + "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":1372700878}, + "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":1372700879}, + "scim": {"limit":9,"remaining":8,"used":1,"reset":1372700880}, + "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":1372700881}, + "code_search": {"limit":11,"remaining":10,"used":1,"reset":1372700882}, + "audit_log": {"limit": 12,"remaining":11,"used":1,"reset":1372700883}, + "dependency_sbom": {"limit": 100,"remaining":100,"used":0,"reset":1372700884} }}`) }) @@ -68,73 +69,73 @@ func TestRateLimits(t *testing.T) { Limit: 2, Remaining: 1, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700873), }, Search: &Rate{ Limit: 3, Remaining: 2, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700874), }, GraphQL: &Rate{ Limit: 4, Remaining: 3, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700875), }, IntegrationManifest: &Rate{ Limit: 5, Remaining: 4, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700876), }, SourceImport: &Rate{ Limit: 6, Remaining: 5, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700877), }, CodeScanningUpload: &Rate{ Limit: 7, Remaining: 6, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700878), }, ActionsRunnerRegistration: &Rate{ Limit: 8, Remaining: 7, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700879), }, SCIM: &Rate{ Limit: 9, Remaining: 8, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700880), }, DependencySnapshots: &Rate{ Limit: 10, Remaining: 9, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700881), }, CodeSearch: &Rate{ Limit: 11, Remaining: 10, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700882), }, AuditLog: &Rate{ Limit: 12, Remaining: 11, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700883), }, DependencySBOM: &Rate{ Limit: 100, Remaining: 100, Used: 0, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700884), }, } if !cmp.Equal(rate, want) { @@ -222,22 +223,22 @@ func TestRateLimits_overQuota(t *testing.T) { Limit: 1, Remaining: 0, Used: 1, - Reset: referenceTimestamp, + Reset: Timestamp{time.Now().Add(time.Hour).Local()}, } mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{"resources":{ - "core": {"limit":2,"remaining":1,"used":1,"reset":`+referenceTimeStr+`}, - "search": {"limit":3,"remaining":2,"used":1,"reset":`+referenceTimeStr+`}, - "graphql": {"limit":4,"remaining":3,"used":1,"reset":`+referenceTimeStr+`}, - "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":`+referenceTimeStr+`}, - "source_import": {"limit":6,"remaining":5,"used":1,"reset":`+referenceTimeStr+`}, - "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":`+referenceTimeStr+`}, - "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":`+referenceTimeStr+`}, - "scim": {"limit":9,"remaining":8,"used":1,"reset":`+referenceTimeStr+`}, - "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":`+referenceTimeStr+`}, - "code_search": {"limit":11,"remaining":10,"used":1,"reset":`+referenceTimeStr+`}, - "audit_log": {"limit":12,"remaining":11,"used":1,"reset":`+referenceTimeStr+`}, - "dependency_sbom": {"limit":13,"remaining":12,"used":1,"reset":`+referenceTimeStr+`} + "core": {"limit":2,"remaining":1,"used":1,"reset":1372700873}, + "search": {"limit":3,"remaining":2,"used":1,"reset":1372700874}, + "graphql": {"limit":4,"remaining":3,"used":1,"reset":1372700875}, + "integration_manifest": {"limit":5,"remaining":4,"used":1,"reset":1372700876}, + "source_import": {"limit":6,"remaining":5,"used":1,"reset":1372700877}, + "code_scanning_upload": {"limit":7,"remaining":6,"used":1,"reset":1372700878}, + "actions_runner_registration": {"limit":8,"remaining":7,"used":1,"reset":1372700879}, + "scim": {"limit":9,"remaining":8,"used":1,"reset":1372700880}, + "dependency_snapshots": {"limit":10,"remaining":9,"used":1,"reset":1372700881}, + "code_search": {"limit":11,"remaining":10,"used":1,"reset":1372700882}, + "audit_log": {"limit":12,"remaining":11,"used":1,"reset":1372700883}, + "dependency_sbom": {"limit":13,"remaining":12,"used":1,"reset":1372700884} }}`) }) @@ -252,73 +253,73 @@ func TestRateLimits_overQuota(t *testing.T) { Limit: 2, Remaining: 1, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700873), }, Search: &Rate{ Limit: 3, Remaining: 2, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700874), }, GraphQL: &Rate{ Limit: 4, Remaining: 3, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700875), }, IntegrationManifest: &Rate{ Limit: 5, Remaining: 4, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700876), }, SourceImport: &Rate{ Limit: 6, Remaining: 5, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700877), }, CodeScanningUpload: &Rate{ Limit: 7, Remaining: 6, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700878), }, ActionsRunnerRegistration: &Rate{ Limit: 8, Remaining: 7, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700879), }, SCIM: &Rate{ Limit: 9, Remaining: 8, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700880), }, DependencySnapshots: &Rate{ Limit: 10, Remaining: 9, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700881), }, CodeSearch: &Rate{ Limit: 11, Remaining: 10, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700882), }, AuditLog: &Rate{ Limit: 12, Remaining: 11, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700883), }, DependencySBOM: &Rate{ Limit: 13, Remaining: 12, Used: 1, - Reset: referenceTimestamp, + Reset: refTimestamp(1372700884), }, } if !cmp.Equal(rate, want) { diff --git a/github/timestamp_test.go b/github/timestamp_test.go index 2ea2164b16b..78a14843c07 100644 --- a/github/timestamp_test.go +++ b/github/timestamp_test.go @@ -23,6 +23,7 @@ const ( var ( referenceTime = time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC) referenceTimestamp = Timestamp{referenceTime} + refTimestamp = func(unix int64) Timestamp { return Timestamp{time.Unix(unix, 0).In(time.UTC).Local()} } unixOrigin = time.Unix(0, 0).In(time.UTC) ) From def77c91c6c13fd74ae54a7519771fb3fa18a76b Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 09:45:12 -0400 Subject: [PATCH 05/34] Revert git_commits_test.go changes Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/git_commits_test.go | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/github/git_commits_test.go b/github/git_commits_test.go index 6a8ef8ceafe..f7febde7246 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -11,6 +11,7 @@ import ( "io" "net/http" "testing" + "time" "github.com/google/go-cmp/cmp" ) @@ -201,15 +202,16 @@ func TestGitService_CreateCommit_WithSigner(t *testing.T) { client, mux, _ := setup(t) signature := "my voice is my password" + date := time.Date(2017, time.May, 4, 0, 3, 43, 0, time.FixedZone("CEST", 2*3600)) author := CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &referenceTimestamp, + Date: &Timestamp{date}, } wantMessage := `tree t parent p -author go-github ` + referenceUnixTimeStr + ` +0000 -committer go-github ` + referenceUnixTimeStr + ` +0000 +author go-github 1493849023 +0200 +committer go-github 1493849023 +0200 Commit Message.` sha := "commitSha" @@ -293,13 +295,15 @@ func TestGitService_createSignatureMessage_nilCommit(t *testing.T) { func TestGitService_createSignatureMessage_nilMessage(t *testing.T) { t.Parallel() + date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") + _, err := createSignatureMessage(&createCommit{ Message: nil, Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &referenceTimestamp, + Date: &Timestamp{date}, }, }) if err == nil { @@ -309,13 +313,14 @@ func TestGitService_createSignatureMessage_nilMessage(t *testing.T) { func TestGitService_createSignatureMessage_emptyMessage(t *testing.T) { t.Parallel() + date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") _, err := createSignatureMessage(&createCommit{ Message: Ptr(""), Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &referenceTimestamp, + Date: &Timestamp{date}, }, }) if err == nil { @@ -337,18 +342,20 @@ func TestGitService_createSignatureMessage_nilAuthor(t *testing.T) { func TestGitService_createSignatureMessage_withoutTree(t *testing.T) { t.Parallel() + date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") + msg, _ := createSignatureMessage(&createCommit{ Message: Ptr("Commit Message."), Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &referenceTimestamp, + Date: &Timestamp{date}, }, }) expected := `parent p -author go-github ` + referenceUnixTimeStr + ` +0000 -committer go-github ` + referenceUnixTimeStr + ` +0000 +author go-github 1493849023 +0200 +committer go-github 1493849023 +0200 Commit Message.` if msg != expected { @@ -358,23 +365,25 @@ Commit Message.` func TestGitService_createSignatureMessage_withoutCommitter(t *testing.T) { t.Parallel() + date, _ := time.Parse("Mon Jan 02 15:04:05 2006 -0700", "Thu May 04 00:03:43 2017 +0200") + msg, _ := createSignatureMessage(&createCommit{ Message: Ptr("Commit Message."), Parents: []string{"p"}, Author: &CommitAuthor{ Name: Ptr("go-github"), Email: Ptr("go-github@github.com"), - Date: &referenceTimestamp, + Date: &Timestamp{date}, }, Committer: &CommitAuthor{ Name: Ptr("foo"), Email: Ptr("foo@example.com"), - Date: &referenceTimestamp, + Date: &Timestamp{date}, }, }) expected := `parent p -author go-github ` + referenceUnixTimeStr + ` +0000 -committer foo ` + referenceUnixTimeStr + ` +0000 +author go-github 1493849023 +0200 +committer foo 1493849023 +0200 Commit Message.` if msg != expected { From edb714ca2ff114801a950f318960f85b3d9625a6 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:27:08 -0400 Subject: [PATCH 06/34] Fix actions_workflow_runs_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_workflow_runs_test.go | 40 +++++++++++------------ github/rate_limit_test.go | 48 ++++++++++++++-------------- github/timestamp_test.go | 3 +- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index 3cf36b73931..1731bd21b6c 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -23,7 +23,7 @@ func TestActionsService_ListWorkflowRunsByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/29679449/runs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"id":399444497,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"id":399444497,"run_number":296,"created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -36,8 +36,8 @@ func TestActionsService_ListWorkflowRunsByID(t *testing.T) { want := &WorkflowRuns{ TotalCount: Ptr(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(runs, want) { @@ -66,7 +66,7 @@ func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/29679449/runs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"id":399444497,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"workflow_runs":[{"id":399444496,"run_number":296,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"id":399444497,"run_number":296,"created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -79,8 +79,8 @@ func TestActionsService_ListWorkflowRunsFileName(t *testing.T) { want := &WorkflowRuns{ TotalCount: Ptr(4), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444496)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: Ptr(int64(399444497)), RunNumber: Ptr(296), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(runs, want) { @@ -108,7 +108,7 @@ func TestActionsService_GetWorkflowRunByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":399444496,"run_number":296,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"id":399444496,"run_number":296,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -120,8 +120,8 @@ func TestActionsService_GetWorkflowRunByID(t *testing.T) { want := &WorkflowRun{ ID: Ptr(int64(399444496)), RunNumber: Ptr(296), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(runs, want) { @@ -150,7 +150,7 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/attempts/3", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"exclude_pull_requests": "true"}) - fmt.Fprint(w, `{"id":399444496,"run_number":296,"run_attempt":3,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"id":399444496,"run_number":296,"run_attempt":3,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) opts := &WorkflowRunAttemptOptions{ExcludePullRequests: Ptr(true)} @@ -164,8 +164,8 @@ func TestActionsService_GetWorkflowRunAttempt(t *testing.T) { ID: Ptr(int64(399444496)), RunNumber: Ptr(296), RunAttempt: Ptr(3), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(runs, want) { @@ -702,8 +702,8 @@ func TestActionsService_ListRepositoryWorkflowRuns(t *testing.T) { testFormValues(t, r, values{"per_page": "2", "page": "2"}) fmt.Fprint(w, `{"total_count":2, "workflow_runs":[ - {"id":298499444,"run_number":301,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}, - {"id":298499445,"run_number":302,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + {"id":298499444,"run_number":301,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}, + {"id":298499445,"run_number":302,"created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -716,8 +716,8 @@ func TestActionsService_ListRepositoryWorkflowRuns(t *testing.T) { expected := &WorkflowRuns{ TotalCount: Ptr(2), WorkflowRuns: []*WorkflowRun{ - {ID: Ptr(int64(298499444)), RunNumber: Ptr(301), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {ID: Ptr(int64(298499445)), RunNumber: Ptr(302), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(298499444)), RunNumber: Ptr(301), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: Ptr(int64(298499445)), RunNumber: Ptr(302), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } @@ -948,7 +948,7 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { "html_url": "hu" }, "wait_timer": 0, - "wait_timer_started_at": `+referenceTimeStr+`, + "wait_timer_started_at": `+refTimeStr(1136178000)+`, "current_user_can_approve": false, "reviewers": [] }, @@ -961,7 +961,7 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { "html_url": "hu" }, "wait_timer": 13, - "wait_timer_started_at": `+referenceTimeStr+`, + "wait_timer_started_at": `+refTimeStr(1136178001)+`, "current_user_can_approve": true, "reviewers": [ { @@ -998,7 +998,7 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { HTMLURL: Ptr("hu"), }, WaitTimer: Ptr(int64(0)), - WaitTimerStartedAt: &referenceTimestamp, + WaitTimerStartedAt: refTimestamp(1136178000), CurrentUserCanApprove: Ptr(false), Reviewers: []*RequiredReviewer{}, }, @@ -1011,7 +1011,7 @@ func TestActionsService_GetPendingDeployments(t *testing.T) { HTMLURL: Ptr("hu"), }, WaitTimer: Ptr(int64(13)), - WaitTimerStartedAt: &referenceTimestamp, + WaitTimerStartedAt: refTimestamp(1136178001), CurrentUserCanApprove: Ptr(true), Reviewers: []*RequiredReviewer{ { diff --git a/github/rate_limit_test.go b/github/rate_limit_test.go index a8c3c8dd2c5..67fde2194c4 100644 --- a/github/rate_limit_test.go +++ b/github/rate_limit_test.go @@ -69,73 +69,73 @@ func TestRateLimits(t *testing.T) { Limit: 2, Remaining: 1, Used: 1, - Reset: refTimestamp(1372700873), + Reset: *refTimestamp(1372700873), }, Search: &Rate{ Limit: 3, Remaining: 2, Used: 1, - Reset: refTimestamp(1372700874), + Reset: *refTimestamp(1372700874), }, GraphQL: &Rate{ Limit: 4, Remaining: 3, Used: 1, - Reset: refTimestamp(1372700875), + Reset: *refTimestamp(1372700875), }, IntegrationManifest: &Rate{ Limit: 5, Remaining: 4, Used: 1, - Reset: refTimestamp(1372700876), + Reset: *refTimestamp(1372700876), }, SourceImport: &Rate{ Limit: 6, Remaining: 5, Used: 1, - Reset: refTimestamp(1372700877), + Reset: *refTimestamp(1372700877), }, CodeScanningUpload: &Rate{ Limit: 7, Remaining: 6, Used: 1, - Reset: refTimestamp(1372700878), + Reset: *refTimestamp(1372700878), }, ActionsRunnerRegistration: &Rate{ Limit: 8, Remaining: 7, Used: 1, - Reset: refTimestamp(1372700879), + Reset: *refTimestamp(1372700879), }, SCIM: &Rate{ Limit: 9, Remaining: 8, Used: 1, - Reset: refTimestamp(1372700880), + Reset: *refTimestamp(1372700880), }, DependencySnapshots: &Rate{ Limit: 10, Remaining: 9, Used: 1, - Reset: refTimestamp(1372700881), + Reset: *refTimestamp(1372700881), }, CodeSearch: &Rate{ Limit: 11, Remaining: 10, Used: 1, - Reset: refTimestamp(1372700882), + Reset: *refTimestamp(1372700882), }, AuditLog: &Rate{ Limit: 12, Remaining: 11, Used: 1, - Reset: refTimestamp(1372700883), + Reset: *refTimestamp(1372700883), }, DependencySBOM: &Rate{ Limit: 100, Remaining: 100, Used: 0, - Reset: refTimestamp(1372700884), + Reset: *refTimestamp(1372700884), }, } if !cmp.Equal(rate, want) { @@ -253,73 +253,73 @@ func TestRateLimits_overQuota(t *testing.T) { Limit: 2, Remaining: 1, Used: 1, - Reset: refTimestamp(1372700873), + Reset: *refTimestamp(1372700873), }, Search: &Rate{ Limit: 3, Remaining: 2, Used: 1, - Reset: refTimestamp(1372700874), + Reset: *refTimestamp(1372700874), }, GraphQL: &Rate{ Limit: 4, Remaining: 3, Used: 1, - Reset: refTimestamp(1372700875), + Reset: *refTimestamp(1372700875), }, IntegrationManifest: &Rate{ Limit: 5, Remaining: 4, Used: 1, - Reset: refTimestamp(1372700876), + Reset: *refTimestamp(1372700876), }, SourceImport: &Rate{ Limit: 6, Remaining: 5, Used: 1, - Reset: refTimestamp(1372700877), + Reset: *refTimestamp(1372700877), }, CodeScanningUpload: &Rate{ Limit: 7, Remaining: 6, Used: 1, - Reset: refTimestamp(1372700878), + Reset: *refTimestamp(1372700878), }, ActionsRunnerRegistration: &Rate{ Limit: 8, Remaining: 7, Used: 1, - Reset: refTimestamp(1372700879), + Reset: *refTimestamp(1372700879), }, SCIM: &Rate{ Limit: 9, Remaining: 8, Used: 1, - Reset: refTimestamp(1372700880), + Reset: *refTimestamp(1372700880), }, DependencySnapshots: &Rate{ Limit: 10, Remaining: 9, Used: 1, - Reset: refTimestamp(1372700881), + Reset: *refTimestamp(1372700881), }, CodeSearch: &Rate{ Limit: 11, Remaining: 10, Used: 1, - Reset: refTimestamp(1372700882), + Reset: *refTimestamp(1372700882), }, AuditLog: &Rate{ Limit: 12, Remaining: 11, Used: 1, - Reset: refTimestamp(1372700883), + Reset: *refTimestamp(1372700883), }, DependencySBOM: &Rate{ Limit: 13, Remaining: 12, Used: 1, - Reset: refTimestamp(1372700884), + Reset: *refTimestamp(1372700884), }, } if !cmp.Equal(rate, want) { diff --git a/github/timestamp_test.go b/github/timestamp_test.go index 78a14843c07..8b31320efbb 100644 --- a/github/timestamp_test.go +++ b/github/timestamp_test.go @@ -23,7 +23,8 @@ const ( var ( referenceTime = time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC) referenceTimestamp = Timestamp{referenceTime} - refTimestamp = func(unix int64) Timestamp { return Timestamp{time.Unix(unix, 0).In(time.UTC).Local()} } + refTimeStr = func(unix int64) string { return `"` + refTimestamp(unix).Format(time.RFC3339) + `"` } + refTimestamp = func(unix int64) *Timestamp { return &Timestamp{time.Unix(unix, 0).In(time.UTC).Local()} } unixOrigin = time.Unix(0, 0).In(time.UTC) ) From 351fafdc4a3fea0ffcadd2e875587cb6d38ce006 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:37:25 -0400 Subject: [PATCH 07/34] Fix actions_secrets_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_secrets_test.go | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index bb7966c283d..776e1b301fb 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -168,7 +168,7 @@ func TestActionsService_ListRepoSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -181,8 +181,8 @@ func TestActionsService_ListRepoSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, - {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "A", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001)}, + {Name: "B", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003)}, }, } if !cmp.Equal(secrets, want) { @@ -211,7 +211,7 @@ func TestActionsService_ListRepoOrgSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/organization-secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -224,8 +224,8 @@ func TestActionsService_ListRepoOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, - {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "A", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001)}, + {Name: "B", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003)}, }, } if !cmp.Equal(secrets, want) { @@ -253,7 +253,7 @@ func TestActionsService_GetRepoSecret(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -264,8 +264,8 @@ func TestActionsService_GetRepoSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: referenceTimestamp, - UpdatedAt: referenceTimestamp, + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), } if !cmp.Equal(secret, want) { t.Errorf("Actions.GetRepoSecret returned %+v, want %+v", secret, want) @@ -395,7 +395,7 @@ func TestActionsService_ListOrgSecrets(t *testing.T) { mux.HandleFunc("/orgs/o/actions/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"all"},{"name":"GH_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}]}`) + fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`,"visibility":"all"},{"name":"GH_TOKEN","created_at":`+refTimeStr(1136178004)+`,"updated_at":`+refTimeStr(1136178005)+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -408,9 +408,9 @@ func TestActionsService_ListOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 3, Secrets: []*Secret{ - {Name: "GIST_ID", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "private"}, - {Name: "DEPLOY_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "all"}, - {Name: "GH_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}, + {Name: "GIST_ID", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001), Visibility: "private"}, + {Name: "DEPLOY_TOKEN", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003), Visibility: "all"}, + {Name: "GH_TOKEN", CreatedAt: *refTimestamp(1136178004), UpdatedAt: *refTimestamp(1136178005), Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}, }, } if !cmp.Equal(secrets, want) { @@ -438,7 +438,7 @@ func TestActionsService_GetOrgSecret(t *testing.T) { mux.HandleFunc("/orgs/o/actions/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories"}`) }) ctx := t.Context() @@ -449,8 +449,8 @@ func TestActionsService_GetOrgSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: referenceTimestamp, - UpdatedAt: referenceTimestamp, + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/actions/secrets/SUPER_SECRET/repositories", } @@ -755,7 +755,7 @@ func TestActionsService_ListEnvSecrets(t *testing.T) { mux.HandleFunc("/repositories/1/environments/e/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -768,8 +768,8 @@ func TestActionsService_ListEnvSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, - {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "A", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001)}, + {Name: "B", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003)}, }, } if !cmp.Equal(secrets, want) { @@ -797,7 +797,7 @@ func TestActionsService_GetEnvSecret(t *testing.T) { mux.HandleFunc("/repositories/1/environments/e/secrets/secret", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"secret","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"secret","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -808,8 +808,8 @@ func TestActionsService_GetEnvSecret(t *testing.T) { want := &Secret{ Name: "secret", - CreatedAt: referenceTimestamp, - UpdatedAt: referenceTimestamp, + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), } if !cmp.Equal(secret, want) { t.Errorf("Actions.GetEnvSecret returned %+v, want %+v", secret, want) From 1f498af750a043947a2786bbba2693451e28396a Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:41:01 -0400 Subject: [PATCH 08/34] Fix actions_variables_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_variables_test.go | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index 238831d702d..782494b3833 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -20,7 +20,7 @@ func TestActionsService_ListRepoVariables(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","value":"BB","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -33,8 +33,8 @@ func TestActionsService_ListRepoVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {Name: "A", Value: "AA", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {Name: "B", Value: "BB", CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(variables, want) { @@ -63,7 +63,7 @@ func TestActionsService_ListRepoOrgVariables(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/organization-variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","value":"BB","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -76,8 +76,8 @@ func TestActionsService_ListRepoOrgVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {Name: "A", Value: "AA", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {Name: "B", Value: "BB", CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(variables, want) { @@ -105,7 +105,7 @@ func TestActionsService_GetRepoVariable(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -117,8 +117,8 @@ func TestActionsService_GetRepoVariable(t *testing.T) { want := &ActionsVariable{ Name: "NAME", Value: "VALUE", - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetRepoVariable returned %+v, want %+v", variable, want) @@ -241,7 +241,7 @@ func TestActionsService_ListOrgVariables(t *testing.T) { mux.HandleFunc("/orgs/o/actions/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"private"},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"all"},{"name":"C","value":"CC","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}]}`) + fmt.Fprint(w, `{"total_count":3,"variables":[{"name":"A","value":"AA","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"visibility":"private"},{"name":"B","value":"BB","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`,"visibility":"all"},{"name":"C","value":"CC","created_at":`+refTimeStr(1136178004)+`,"updated_at":`+refTimeStr(1136178005)+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -254,9 +254,9 @@ func TestActionsService_ListOrgVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 3, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, Visibility: Ptr("private")}, - {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, Visibility: Ptr("all")}, - {Name: "C", Value: "CC", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp, Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories")}, + {Name: "A", Value: "AA", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001), Visibility: Ptr("private")}, + {Name: "B", Value: "BB", CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003), Visibility: Ptr("all")}, + {Name: "C", Value: "CC", CreatedAt: refTimestamp(1136178004), UpdatedAt: refTimestamp(1136178005), Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories")}, }, } if !cmp.Equal(variables, want) { @@ -284,7 +284,7 @@ func TestActionsService_GetOrgVariable(t *testing.T) { mux.HandleFunc("/orgs/o/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}`) + fmt.Fprint(w, `{"name":"NAME","value":"VALUE","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"}`) }) ctx := t.Context() @@ -296,8 +296,8 @@ func TestActionsService_GetOrgVariable(t *testing.T) { want := &ActionsVariable{ Name: "NAME", Value: "VALUE", - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Visibility: Ptr("selected"), SelectedRepositoriesURL: Ptr("https://api.github.com/orgs/octo-org/actions/variables/VAR/repositories"), } @@ -568,7 +568,7 @@ func TestActionsService_ListEnvVariables(t *testing.T) { mux.HandleFunc("/repos/usr/1/environments/e/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","value":"BB","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","value":"BB","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -581,8 +581,8 @@ func TestActionsService_ListEnvVariables(t *testing.T) { want := &ActionsVariables{ TotalCount: 4, Variables: []*ActionsVariable{ - {Name: "A", Value: "AA", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {Name: "B", Value: "BB", CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {Name: "A", Value: "AA", CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {Name: "B", Value: "BB", CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(variables, want) { @@ -610,7 +610,7 @@ func TestActionsService_GetEnvVariable(t *testing.T) { mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"variable","value":"VAR","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"variable","value":"VAR","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -622,8 +622,8 @@ func TestActionsService_GetEnvVariable(t *testing.T) { want := &ActionsVariable{ Name: "variable", Value: "VAR", - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(variable, want) { t.Errorf("Actions.GetEnvVariable returned %+v, want %+v", variable, want) From 6cb88eccac45eff3c895b71021610b2be4a8a67b Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:43:25 -0400 Subject: [PATCH 09/34] Fix actions_workflow_jobs_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_workflow_jobs_test.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 3fd07256993..519fbd4ff55 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -23,7 +23,7 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`},{"id":399444497,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+refTimeStr(1136178000)+`,"completed_at":`+refTimeStr(1136178001)+`},{"id":399444497,"run_id":29679449,"started_at":`+refTimeStr(1136178002)+`,"completed_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListWorkflowJobsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -36,8 +36,8 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { want := &Jobs{ TotalCount: Ptr(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, - {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001)}, + {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(jobs, want) { @@ -66,7 +66,7 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"filter": "all", "per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`},{"id":399444497,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+refTimeStr(1136178000)+`,"completed_at":`+refTimeStr(1136178001)+`},{"id":399444497,"run_id":29679449,"started_at":`+refTimeStr(1136178002)+`,"completed_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListWorkflowJobsOptions{Filter: "all", ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -79,8 +79,8 @@ func TestActionsService_ListWorkflowJobs_Filter(t *testing.T) { want := &Jobs{ TotalCount: Ptr(4), Jobs: []*WorkflowJob{ - {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, - {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: &referenceTimestamp, CompletedAt: &referenceTimestamp}, + {ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178000), CompletedAt: refTimestamp(1136178001)}, + {ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), StartedAt: refTimestamp(1136178002), CompletedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(jobs, want) { @@ -95,7 +95,7 @@ func TestActionsService_ListWorkflowJobsAttempt(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/runs/29679449/attempts/1/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`,"run_attempt":2},{"id":399444497,"run_id":29679449,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`,"run_attempt":2}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":`+refTimeStr(1136178000)+`,"completed_at":`+refTimeStr(1136178001)+`,"run_attempt":2},{"id":399444497,"run_id":29679449,"started_at":`+refTimeStr(1136178002)+`,"completed_at":`+refTimeStr(1136178003)+`,"run_attempt":2}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} ctx := t.Context() @@ -110,15 +110,15 @@ func TestActionsService_ListWorkflowJobsAttempt(t *testing.T) { { ID: Ptr(int64(399444496)), RunID: Ptr(int64(29679449)), - StartedAt: &referenceTimestamp, - CompletedAt: &referenceTimestamp, + StartedAt: refTimestamp(1136178000), + CompletedAt: refTimestamp(1136178001), RunAttempt: Ptr(int64(2)), }, { ID: Ptr(int64(399444497)), RunID: Ptr(int64(29679449)), - StartedAt: &referenceTimestamp, - CompletedAt: &referenceTimestamp, + StartedAt: refTimestamp(1136178002), + CompletedAt: refTimestamp(1136178003), RunAttempt: Ptr(int64(2)), }, }, @@ -148,7 +148,7 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/jobs/399444496", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":399444496,"started_at":`+referenceTimeStr+`,"completed_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"id":399444496,"started_at":`+refTimeStr(1136178000)+`,"completed_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -159,8 +159,8 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { want := &WorkflowJob{ ID: Ptr(int64(399444496)), - StartedAt: &referenceTimestamp, - CompletedAt: &referenceTimestamp, + StartedAt: refTimestamp(1136178000), + CompletedAt: refTimestamp(1136178001), } if !cmp.Equal(job, want) { t.Errorf("Actions.GetWorkflowJobByID returned %+v, want %+v", job, want) From d8e0dc880d16ea9ebc4f28feaf41ea1fb2470ddb Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:46:15 -0400 Subject: [PATCH 10/34] Fix actions_workflows_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/actions_workflows_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index b8496412230..a1c9ca728b1 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -20,7 +20,7 @@ func TestActionsService_ListWorkflows(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"id":72845,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"id":72845,"created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -33,8 +33,8 @@ func TestActionsService_ListWorkflows(t *testing.T) { want := &Workflows{ TotalCount: Ptr(4), Workflows: []*Workflow{ - {ID: Ptr(int64(72844)), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, - {ID: Ptr(int64(72845)), CreatedAt: &referenceTimestamp, UpdatedAt: &referenceTimestamp}, + {ID: Ptr(int64(72844)), CreatedAt: refTimestamp(1136178000), UpdatedAt: refTimestamp(1136178001)}, + {ID: Ptr(int64(72845)), CreatedAt: refTimestamp(1136178002), UpdatedAt: refTimestamp(1136178003)}, }, } if !cmp.Equal(workflows, want) { @@ -62,7 +62,7 @@ func TestActionsService_GetWorkflowByID(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/72844", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":72844,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"id":72844,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -73,8 +73,8 @@ func TestActionsService_GetWorkflowByID(t *testing.T) { want := &Workflow{ ID: Ptr(int64(72844)), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(workflow, want) { t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want) @@ -101,7 +101,7 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/workflows/main.yml", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":72844,"created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"id":72844,"created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -112,8 +112,8 @@ func TestActionsService_GetWorkflowByFileName(t *testing.T) { want := &Workflow{ ID: Ptr(int64(72844)), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(workflow, want) { t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want) From 36d22feeaa53fbc12863f2e8f4e4f96c0d46d2e3 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:53:50 -0400 Subject: [PATCH 11/34] Fix activity_notifications_test.go and repos_commits_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/activity_notifications_test.go | 5 +++-- github/repos_commits_test.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 009ab08f9ef..ef91f0b4303 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "testing" + "time" "github.com/google/go-cmp/cmp" ) @@ -23,7 +24,7 @@ func TestActivityService_ListNotification(t *testing.T) { "all": "true", "participating": "true", "since": referenceTimeRaw, - "before": referenceTimeRaw, + "before": "2007-03-04T15:04:05Z", }) fmt.Fprint(w, `[{"id":"1", "subject":{"title":"t"}}]`) @@ -33,7 +34,7 @@ func TestActivityService_ListNotification(t *testing.T) { All: true, Participating: true, Since: referenceTime, - Before: referenceTime, + Before: time.Date(2007, time.March, 4, 15, 4, 5, 0, time.UTC), } ctx := t.Context() notifications, _, err := client.Activity.ListNotifications(ctx, opt) diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 1133ecd5e93..1ca3c1f4338 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -11,6 +11,7 @@ import ( "net/url" "strings" "testing" + "time" "github.com/google/go-cmp/cmp" ) @@ -28,7 +29,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { "path": "p", "author": "a", "since": referenceTimeRaw, - "until": referenceTimeRaw, + "until": "2007-03-04T15:04:05Z", }) fmt.Fprint(w, `[{"sha": "s"}]`) }) @@ -38,7 +39,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { Path: "p", Author: "a", Since: referenceTime, - Until: referenceTime, + Until: time.Date(2007, time.March, 4, 15, 4, 5, 0, time.UTC), } ctx := t.Context() commits, _, err := client.Repositories.ListCommits(ctx, "o", "r", opt) From 89e2c28161c184d387f4ed39ae3d3a1b4c835fbb Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:55:45 -0400 Subject: [PATCH 12/34] Fix admin_users_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/admin_users_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/admin_users_test.go b/github/admin_users_test.go index d39414a3878..bf462a8b2de 100644 --- a/github/admin_users_test.go +++ b/github/admin_users_test.go @@ -92,8 +92,8 @@ func TestUserImpersonation_Create(t *testing.T) { "token_last_eight": "1234", "note": null, "note_url": null, - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "scopes": [ "repo" ], @@ -119,8 +119,8 @@ func TestUserImpersonation_Create(t *testing.T) { TokenLastEight: Ptr("1234"), Note: nil, NoteURL: nil, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Scopes: []string{"repo"}, Fingerprint: nil, } From 4646a70298e17515ae1a28b061f5ea24cd89ba2e Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:58:22 -0400 Subject: [PATCH 13/34] Fix apps_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/apps_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/apps_test.go b/github/apps_test.go index 93b34482817..d936a4f3aac 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -174,8 +174,8 @@ func TestAppsService_ListInstallations(t *testing.T) { ], "single_file_name": "config.yml", "repository_selection": "selected", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`}]`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`}]`, ) }) @@ -232,8 +232,8 @@ func TestAppsService_ListInstallations(t *testing.T) { Workflows: Ptr("write"), }, Events: []string{"push", "pull_request"}, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), }} if !cmp.Equal(installations, want) { t.Errorf("Apps.ListInstallations returned %+v, want %+v", installations, want) From 37db75cfcd11846eebfaf383e3f940120e3a331a Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:03:16 -0400 Subject: [PATCH 14/34] Fix code_scanning_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/code_scanning_test.go | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/github/code_scanning_test.go b/github/code_scanning_test.go index 713cd841c68..785cec746ba 100644 --- a/github/code_scanning_test.go +++ b/github/code_scanning_test.go @@ -1022,7 +1022,6 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { t.Errorf("CodeScanning.ListAnalysesForRepo returned error: %v", err) } - date := &referenceTimestamp want := []*ScanningAnalysis{ { ID: Ptr(int64(201)), @@ -1032,7 +1031,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { Environment: Ptr("{\"language\":\"python\"}"), Error: Ptr(""), Category: Ptr(".github/workflows/codeql-analysis.yml:analyze/language:python"), - CreatedAt: date, + CreatedAt: &referenceTimestamp, ResultsCount: Ptr(17), RulesCount: Ptr(49), URL: Ptr("https://api.github.com/repos/o/r/code-scanning/analyses/201"), @@ -1053,7 +1052,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { Environment: Ptr("{}"), Error: Ptr(""), Category: Ptr(".github/workflows/shiftleft.yml:build/"), - CreatedAt: date, + CreatedAt: &referenceTimestamp, ResultsCount: Ptr(17), RulesCount: Ptr(32), URL: Ptr("https://api.github.com/repos/o/r/code-scanning/analyses/200"), @@ -1121,7 +1120,6 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { t.Errorf("CodeScanning.GetAnalysis returned error: %v", err) } - date := &referenceTimestamp want := &ScanningAnalysis{ ID: Ptr(int64(3602840)), Ref: Ptr("refs/heads/main"), @@ -1130,7 +1128,7 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { Environment: Ptr("{\"language\":\"javascript\"}"), Error: Ptr(""), Category: Ptr(".github/workflows/codeql-analysis.yml:analyze/language:javascript"), - CreatedAt: date, + CreatedAt: &referenceTimestamp, ResultsCount: Ptr(3), RulesCount: Ptr(67), URL: Ptr("https://api.github.com/repos/o/r/code-scanning/analyses/201"), @@ -1236,8 +1234,8 @@ func TestCodeScanningService_ListCodeQLDatabases(t *testing.T) { }, "content_type": "r", "size": 1024, - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "url": "s" } ]`) @@ -1249,7 +1247,6 @@ func TestCodeScanningService_ListCodeQLDatabases(t *testing.T) { t.Errorf("CodeScanning.ListCodeQLDatabases returned error: %v", err) } - date := &referenceTimestamp want := []*CodeQLDatabase{ { ID: Ptr(int64(1)), @@ -1277,8 +1274,8 @@ func TestCodeScanningService_ListCodeQLDatabases(t *testing.T) { }, ContentType: Ptr("r"), Size: Ptr(int64(1024)), - CreatedAt: date, - UpdatedAt: date, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), URL: Ptr("s"), }, } @@ -1334,8 +1331,8 @@ func TestCodeScanningService_GetCodeQLDatabase(t *testing.T) { }, "content_type": "r", "size": 1024, - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "url": "s" }`) }) @@ -1346,7 +1343,6 @@ func TestCodeScanningService_GetCodeQLDatabase(t *testing.T) { t.Errorf("CodeScanning.GetCodeQLDatabase returned error: %v", err) } - date := &referenceTimestamp want := &CodeQLDatabase{ ID: Ptr(int64(1)), Name: Ptr("name"), @@ -1373,8 +1369,8 @@ func TestCodeScanningService_GetCodeQLDatabase(t *testing.T) { }, ContentType: Ptr("r"), Size: Ptr(int64(1024)), - CreatedAt: date, - UpdatedAt: date, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), URL: Ptr("s"), } @@ -1424,12 +1420,11 @@ func TestCodeScanningService_GetDefaultSetupConfiguration(t *testing.T) { t.Errorf("CodeScanning.GetDefaultSetupConfiguration returned error: %v", err) } - date := &referenceTimestamp want := &DefaultSetupConfiguration{ State: Ptr("configured"), Languages: []string{"javascript", "javascript-typescript", "typescript"}, QuerySuite: Ptr("default"), - UpdatedAt: date, + UpdatedAt: &referenceTimestamp, } if !cmp.Equal(cfg, want) { t.Errorf("CodeScanning.GetDefaultSetupConfiguration returned %+v, want %+v", cfg, want) From 94a5fde249febb5dd7d7b05f11ecf7722bc5fed4 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:07:01 -0400 Subject: [PATCH 15/34] Fix codespaces_secrets_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/codespaces_secrets_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/github/codespaces_secrets_test.go b/github/codespaces_secrets_test.go index 3a5210e552b..d495b7003d5 100644 --- a/github/codespaces_secrets_test.go +++ b/github/codespaces_secrets_test.go @@ -31,7 +31,7 @@ func TestCodespacesService_ListSecrets(t *testing.T) { mux.HandleFunc("/user/codespaces/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) }, call: func(ctx context.Context, client *Client) (*Secrets, *Response, error) { @@ -45,7 +45,7 @@ func TestCodespacesService_ListSecrets(t *testing.T) { mux.HandleFunc("/orgs/o/codespaces/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) }, call: func(ctx context.Context, client *Client) (*Secrets, *Response, error) { @@ -62,7 +62,7 @@ func TestCodespacesService_ListSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/codespaces/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) }, call: func(ctx context.Context, client *Client) (*Secrets, *Response, error) { @@ -91,8 +91,8 @@ func TestCodespacesService_ListSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, - {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "A", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001)}, + {Name: "B", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003)}, }, } if !cmp.Equal(secrets, want) { @@ -132,7 +132,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/user/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) }, call: func(ctx context.Context, client *Client) (*Secret, *Response, error) { @@ -145,7 +145,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/orgs/o/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) }, call: func(ctx context.Context, client *Client) (*Secret, *Response, error) { @@ -161,7 +161,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/repos/o/r/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) }, call: func(ctx context.Context, client *Client) (*Secret, *Response, error) { @@ -187,7 +187,7 @@ func TestCodespacesService_GetSecret(t *testing.T) { t.Errorf("Codespaces.%v returned error: %v", tt.methodName, err) } - want := &Secret{Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp} + want := &Secret{Name: "A", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001)} if !cmp.Equal(secret, want) { t.Errorf("Codespaces.%v returned %+v, want %+v", tt.methodName, secret, want) } From 76b4362d7272426f77533f78bc6cb8e1962abafd Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:11:06 -0400 Subject: [PATCH 16/34] Fix codespaces_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/codespaces_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/codespaces_test.go b/github/codespaces_test.go index 664d03ffad2..7be8eb434f8 100644 --- a/github/codespaces_test.go +++ b/github/codespaces_test.go @@ -23,7 +23,7 @@ func TestCodespacesService_ListInRepo(t *testing.T) { "page": "1", "per_page": "2", }) - fmt.Fprint(w, `{"total_count":2,"codespaces":[{"id":1,"name":"monalisa-octocat-hello-world-g4wpq6h95q","environment_id":"26a7c758-7299-4a73-b978-5a92a7ae98a0","owner":{"login":"octocat"},"billable_owner":{"login":"octocat"},"repository":{"id":1296269},"machine":{"name":"standardLinux","display_name":"4 cores, 8 GB RAM, 64 GB storage","operating_system":"linux","storage_in_bytes":68719476736,"memory_in_bytes":8589934592,"cpus":4},"prebuild":false,"devcontainer_path":".devcontainer/devcontainer.json","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"last_used_at":`+referenceTimeStr+`,"state":"Available","url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q","git_status":{"ahead":0,"behind":0,"has_unpushed_changes":false,"has_uncommitted_changes":false,"ref":"main"},"location":"WestUs2","idle_timeout_minutes":60,"web_url":"https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev","machines_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines","start_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start","stop_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop","recent_folders":["testfolder1","testfolder2"]},{"id":2}]}`) + fmt.Fprint(w, `{"total_count":2,"codespaces":[{"id":1,"name":"monalisa-octocat-hello-world-g4wpq6h95q","environment_id":"26a7c758-7299-4a73-b978-5a92a7ae98a0","owner":{"login":"octocat"},"billable_owner":{"login":"octocat"},"repository":{"id":1296269},"machine":{"name":"standardLinux","display_name":"4 cores, 8 GB RAM, 64 GB storage","operating_system":"linux","storage_in_bytes":68719476736,"memory_in_bytes":8589934592,"cpus":4},"prebuild":false,"devcontainer_path":".devcontainer/devcontainer.json","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"last_used_at":`+refTimeStr(1136178002)+`,"state":"Available","url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q","git_status":{"ahead":0,"behind":0,"has_unpushed_changes":false,"has_uncommitted_changes":false,"ref":"main"},"location":"WestUs2","idle_timeout_minutes":60,"web_url":"https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev","machines_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines","start_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start","stop_url":"https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop","recent_folders":["testfolder1","testfolder2"]},{"id":2}]}`) }) opt := &ListOptions{Page: 1, PerPage: 2} @@ -57,9 +57,9 @@ func TestCodespacesService_ListInRepo(t *testing.T) { }, Prebuild: Ptr(false), DevcontainerPath: Ptr(".devcontainer/devcontainer.json"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, - LastUsedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), + LastUsedAt: refTimestamp(1136178002), State: Ptr("Available"), URL: Ptr("https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q"), GitStatus: &CodespacesGitStatus{ From ab27bddb420973ca4fb5ae79e3d49fe2a306bd4b Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:15:43 -0400 Subject: [PATCH 17/34] Fix copilot_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/copilot_test.go | 96 +++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index 81ae69a3efd..8f3cfef2fac 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -356,10 +356,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { "total_seats": 4, "seats": [ { - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": null, - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octocat", @@ -398,10 +398,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { } }, { - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octokitten", @@ -425,10 +425,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { } }, { - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "name": "octokittens", @@ -437,10 +437,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { } }, { - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "name": "octocats", @@ -499,10 +499,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Parent: nil, }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: nil, - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -527,10 +527,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { SiteAdmin: Ptr(false), }, AssigningTeam: nil, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -540,10 +540,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Type: Ptr("Team"), }, AssigningTeam: nil, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, { @@ -553,10 +553,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { Type: Ptr("Organization"), }, AssigningTeam: nil, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), }, }, @@ -594,10 +594,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { "total_seats": 2, "seats": [ { - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": null, - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "plan_type": "business", "assignee": { @@ -637,10 +637,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { } }, { - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": "2021-11-01", - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octokitten", @@ -713,10 +713,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), Parent: nil, }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: nil, - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), PlanType: Ptr("business"), }, @@ -742,10 +742,10 @@ func TestCopilotService_ListCopilotEnterpriseSeats(t *testing.T) { SiteAdmin: Ptr(false), }, AssigningTeam: nil, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: Ptr("2021-11-01"), - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), PlanType: nil, }, @@ -1052,10 +1052,10 @@ func TestCopilotService_GetSeatDetails(t *testing.T) { mux.HandleFunc("/orgs/o/members/u/copilot", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{ - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "pending_cancellation_date": null, - "last_activity_at": `+referenceTimeStr+`, + "last_activity_at": `+refTimeStr(1136178002)+`, "last_activity_editor": "vscode/1.77.3/copilot/1.86.82", "assignee": { "login": "octocat", @@ -1137,10 +1137,10 @@ func TestCopilotService_GetSeatDetails(t *testing.T) { RepositoriesURL: Ptr("https://api.github.com/teams/1/repos"), Parent: nil, }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), PendingCancellationDate: nil, - LastActivityAt: &referenceTimestamp, + LastActivityAt: refTimestamp(1136178002), LastActivityEditor: Ptr("vscode/1.77.3/copilot/1.86.82"), } @@ -3168,7 +3168,7 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { "report_start_day": "2026-03-05", "report_end_day": "2026-04-01", "organization_id": "123", - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "day_totals": [ { "day": "2026-03-05", @@ -3209,7 +3209,7 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { ReportStartDay: "2026-03-05", ReportEndDay: "2026-04-01", OrganizationID: Ptr("123"), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), DayTotals: []*CopilotDailyMetrics{ { Day: "2026-03-05", @@ -3268,7 +3268,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { mux.HandleFunc("/path/to/users-daily", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"user_id":1,"user_login":"alice","day":"2026-04-01","user_initiated_interaction_count":5,"chat_panel_edit_mode":2,"used_chat":true,"used_cli":true,"used_copilot_code_review_active":true,"totals_by_cli":{"session_count":2,"request_count":2,"prompt_count":1,"last_known_cli_version":{"sampled_at":`+referenceTimeStr+`,"cli_version":"1.0.8"}},"totals_by_ide":[{"ide":"vscode","user_initiated_interaction_count":5,"last_known_plugin_version":{"sampled_at":`+referenceTimeStr+`,"plugin":"copilot","plugin_version":"1.0.0"},"last_known_ide_version":{"sampled_at":`+referenceTimeStr+`,"ide_version":"1.90"}}]} + fmt.Fprint(w, `{"user_id":1,"user_login":"alice","day":"2026-04-01","user_initiated_interaction_count":5,"chat_panel_edit_mode":2,"used_chat":true,"used_cli":true,"used_copilot_code_review_active":true,"totals_by_cli":{"session_count":2,"request_count":2,"prompt_count":1,"last_known_cli_version":{"sampled_at":`+refTimeStr(1136178000)+`,"cli_version":"1.0.8"}},"totals_by_ide":[{"ide":"vscode","user_initiated_interaction_count":5,"last_known_plugin_version":{"sampled_at":`+refTimeStr(1136178001)+`,"plugin":"copilot","plugin_version":"1.0.0"},"last_known_ide_version":{"sampled_at":`+refTimeStr(1136178002)+`,"ide_version":"1.90"}}]} {"user_id":2,"user_login":"bob","day":"2026-04-01","used_agent":true,"used_copilot_code_review_passive":true} `) }) @@ -3300,7 +3300,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { RequestCount: Ptr(2), PromptCount: Ptr(1), LastKnownCLIVersion: &CopilotMetricsCLIVersion{ - SampledAt: &referenceTimestamp, + SampledAt: refTimestamp(1136178000), CLIVersion: "1.0.8", }, }, @@ -3309,12 +3309,12 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) { IDE: "vscode", UserInitiatedInteractionCount: Ptr(5), LastKnownPluginVersion: &CopilotUserMetricsPluginVersion{ - SampledAt: &referenceTimestamp, + SampledAt: refTimestamp(1136178001), Plugin: "copilot", PluginVersion: "1.0.0", }, LastKnownIDEVersion: &CopilotUserMetricsIDEVersion{ - SampledAt: &referenceTimestamp, + SampledAt: refTimestamp(1136178002), IDEVersion: "1.90", }, }, From f2ef4eaef4b4ff965de4afa9bba2766fbd7929e7 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:19:10 -0400 Subject: [PATCH 18/34] Fix dependabot_secrets_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/dependabot_secrets_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/github/dependabot_secrets_test.go b/github/dependabot_secrets_test.go index de407fb9dde..0168293d15c 100644 --- a/github/dependabot_secrets_test.go +++ b/github/dependabot_secrets_test.go @@ -90,7 +90,7 @@ func TestDependabotService_ListRepoSecrets(t *testing.T) { mux.HandleFunc("/repos/o/r/dependabot/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`},{"name":"B","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}]}`) + fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`},{"name":"B","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -103,8 +103,8 @@ func TestDependabotService_ListRepoSecrets(t *testing.T) { want := &Secrets{ TotalCount: 4, Secrets: []*Secret{ - {Name: "A", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, - {Name: "B", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp}, + {Name: "A", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001)}, + {Name: "B", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003)}, }, } if !cmp.Equal(secrets, want) { @@ -132,7 +132,7 @@ func TestDependabotService_GetRepoSecret(t *testing.T) { mux.HandleFunc("/repos/o/r/dependabot/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`}`) }) ctx := t.Context() @@ -143,8 +143,8 @@ func TestDependabotService_GetRepoSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: referenceTimestamp, - UpdatedAt: referenceTimestamp, + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), } if !cmp.Equal(secret, want) { t.Errorf("Dependabot.GetRepoSecret returned %+v, want %+v", secret, want) @@ -274,7 +274,7 @@ func TestDependabotService_ListOrgSecrets(t *testing.T) { mux.HandleFunc("/orgs/o/dependabot/secrets", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"all"},{"name":"GH_TOKEN","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}]}`) + fmt.Fprint(w, `{"total_count":3,"secrets":[{"name":"GIST_ID","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"visibility":"private"},{"name":"DEPLOY_TOKEN","created_at":`+refTimeStr(1136178002)+`,"updated_at":`+refTimeStr(1136178003)+`,"visibility":"all"},{"name":"GH_TOKEN","created_at":`+refTimeStr(1136178004)+`,"updated_at":`+refTimeStr(1136178005)+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} @@ -287,9 +287,9 @@ func TestDependabotService_ListOrgSecrets(t *testing.T) { want := &Secrets{ TotalCount: 3, Secrets: []*Secret{ - {Name: "GIST_ID", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "private"}, - {Name: "DEPLOY_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "all"}, - {Name: "GH_TOKEN", CreatedAt: referenceTimestamp, UpdatedAt: referenceTimestamp, Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}, + {Name: "GIST_ID", CreatedAt: *refTimestamp(1136178000), UpdatedAt: *refTimestamp(1136178001), Visibility: "private"}, + {Name: "DEPLOY_TOKEN", CreatedAt: *refTimestamp(1136178002), UpdatedAt: *refTimestamp(1136178003), Visibility: "all"}, + {Name: "GH_TOKEN", CreatedAt: *refTimestamp(1136178004), UpdatedAt: *refTimestamp(1136178005), Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}, }, } if !cmp.Equal(secrets, want) { @@ -317,7 +317,7 @@ func TestDependabotService_GetOrgSecret(t *testing.T) { mux.HandleFunc("/orgs/o/dependabot/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"name":"NAME","created_at":`+referenceTimeStr+`,"updated_at":`+referenceTimeStr+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}`) + fmt.Fprint(w, `{"name":"NAME","created_at":`+refTimeStr(1136178000)+`,"updated_at":`+refTimeStr(1136178001)+`,"visibility":"selected","selected_repositories_url":"https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories"}`) }) ctx := t.Context() @@ -328,8 +328,8 @@ func TestDependabotService_GetOrgSecret(t *testing.T) { want := &Secret{ Name: "NAME", - CreatedAt: referenceTimestamp, - UpdatedAt: referenceTimestamp, + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), Visibility: "selected", SelectedRepositoriesURL: "https://api.github.com/orgs/octo-org/dependabot/secrets/SUPER_SECRET/repositories", } From 2f7e9255a8cd6675545e4c0a12ac17178a7a93af Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:53:30 -0400 Subject: [PATCH 19/34] Fix enterprise_manage_ghes_config_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/enterprise_manage_ghes_config_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/github/enterprise_manage_ghes_config_test.go b/github/enterprise_manage_ghes_config_test.go index 7f5ececcf4a..cc43ead90b9 100644 --- a/github/enterprise_manage_ghes_config_test.go +++ b/github/enterprise_manage_ghes_config_test.go @@ -414,10 +414,10 @@ func TestEnterpriseService_License(t *testing.T) { "croquetSupport": true, "customTerms": true, "evaluation": false, - "expireAt": `+referenceTimeStr+`, + "expireAt": `+refTimeStr(1136178000)+`, "insightsEnabled": true, - "insightsExpireAt": `+referenceTimeStr+`, - "learningLabEvaluationExpires": `+referenceTimeStr+`, + "insightsExpireAt": `+refTimeStr(1136178001)+`, + "learningLabEvaluationExpires": `+refTimeStr(1136178002)+`, "learningLabSeats": 100, "perpetual": false, "referenceNumber": "32a145", @@ -442,10 +442,10 @@ func TestEnterpriseService_License(t *testing.T) { CroquetSupport: Ptr(true), CustomTerms: Ptr(true), Evaluation: Ptr(false), - ExpireAt: &referenceTimestamp, + ExpireAt: refTimestamp(1136178000), InsightsEnabled: Ptr(true), - InsightsExpireAt: &referenceTimestamp, - LearningLabEvaluationExpires: &referenceTimestamp, + InsightsExpireAt: refTimestamp(1136178001), + LearningLabEvaluationExpires: refTimestamp(1136178002), LearningLabSeats: Ptr(100), Perpetual: Ptr(false), ReferenceNumber: Ptr("32a145"), From 299439870ebc8167c946dac4a5311bb06710a5ea Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:54:57 -0400 Subject: [PATCH 20/34] Fix enterprise_team_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/enterprise_team_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/enterprise_team_test.go b/github/enterprise_team_test.go index 0b9bbb1265f..e8a9562fcae 100644 --- a/github/enterprise_team_test.go +++ b/github/enterprise_team_test.go @@ -26,8 +26,8 @@ func TestEnterpriseService_ListTeams(t *testing.T) { "name": "Team One", "html_url": "https://example.com/html", "slug": "team-one", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "group_id": "99" }]`) }) @@ -48,8 +48,8 @@ func TestEnterpriseService_ListTeams(t *testing.T) { HTMLURL: "https://example.com/html", Slug: "team-one", GroupID: "99", - CreatedAt: referenceTimestamp, - UpdatedAt: referenceTimestamp, + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), }, } From aafb0b4e775fc60479d616c63d960f564de2ebe4 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:56:23 -0400 Subject: [PATCH 21/34] Fix gists_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/gists_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/gists_test.go b/github/gists_test.go index 0ed629dd482..1c7d6fe26d7 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -714,8 +714,8 @@ func TestGistsService_ListForks(t *testing.T) { {"url": "https://api.github.com/gists/1", "user": {"id": 1}, "id": "1", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` } ] `) @@ -731,8 +731,8 @@ func TestGistsService_ListForks(t *testing.T) { URL: Ptr("https://api.github.com/gists/1"), ID: Ptr("1"), User: &User{ID: Ptr(int64(1))}, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), }} if !cmp.Equal(gistForks, want) { From 1e0433d5edeaeefba441b39fe4055f4e27797506 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:58:13 -0400 Subject: [PATCH 22/34] Fix github/orgs_credential_authorizations_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/orgs_credential_authorizations_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/orgs_credential_authorizations_test.go b/github/orgs_credential_authorizations_test.go index 7938a9de100..8770c77c8ec 100644 --- a/github/orgs_credential_authorizations_test.go +++ b/github/orgs_credential_authorizations_test.go @@ -25,8 +25,8 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { "login": "l", "credential_id": 1, "credential_type": "t", - "credential_authorized_at": `+referenceTimeStr+`, - "credential_accessed_at": `+referenceTimeStr+`, + "credential_authorized_at": `+refTimeStr(1136178000)+`, + "credential_accessed_at": `+refTimeStr(1136178001)+`, "authorized_credential_id": 1 } ]`) @@ -48,8 +48,8 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { Login: Ptr("l"), CredentialID: Ptr(int64(1)), CredentialType: Ptr("t"), - CredentialAuthorizedAt: &referenceTimestamp, - CredentialAccessedAt: &referenceTimestamp, + CredentialAuthorizedAt: refTimestamp(1136178000), + CredentialAccessedAt: refTimestamp(1136178001), AuthorizedCredentialID: Ptr(int64(1)), }, } From 8a72a2bdcacadb2e134372e90392202dc6dbace9 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:59:14 -0400 Subject: [PATCH 23/34] Fix github/orgs_custom_repository_roles_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/orgs_custom_repository_roles_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github/orgs_custom_repository_roles_test.go b/github/orgs_custom_repository_roles_test.go index ea25ad915ea..38a2e5b4182 100644 --- a/github/orgs_custom_repository_roles_test.go +++ b/github/orgs_custom_repository_roles_test.go @@ -37,8 +37,8 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) { "location": "l", "email": "e" }, - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` } ] }`) @@ -70,8 +70,8 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) { Location: Ptr("l"), Email: Ptr("e"), }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), }, }, } @@ -117,8 +117,8 @@ func TestOrganizationsService_GetCustomRepoRole(t *testing.T) { "location": "l", "email": "e" }, - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }`) }) @@ -145,8 +145,8 @@ func TestOrganizationsService_GetCustomRepoRole(t *testing.T) { Location: Ptr("l"), Email: Ptr("e"), }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(role, want) { t.Errorf("Organizations.GetCustomRepoRole returned %+v, want %+v", role, want) From 8e3511b7facf37187a7c7ecc3f982d660477bf4a Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:00:24 -0400 Subject: [PATCH 24/34] Fix github/orgs_issue_types_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/orgs_issue_types_test.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/github/orgs_issue_types_test.go b/github/orgs_issue_types_test.go index 856bd182187..dad06d3cbf0 100644 --- a/github/orgs_issue_types_test.go +++ b/github/orgs_issue_types_test.go @@ -25,16 +25,16 @@ func TestOrganizationsService_ListIssueTypes(t *testing.T) { "node_id": "IT_kwDNAd3NAZo", "name": "Task", "description": "A specific piece of work", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }, { "id": 411, "node_id": "IT_kwDNAd3NAZs", "name": "Bug", "description": "An unexpected problem or behavior", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178002)+`, + "updated_at": `+refTimeStr(1136178003)+` } ]`) }) @@ -51,16 +51,16 @@ func TestOrganizationsService_ListIssueTypes(t *testing.T) { NodeID: Ptr("IT_kwDNAd3NAZo"), Name: Ptr("Task"), Description: Ptr("A specific piece of work"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), }, { ID: Ptr(int64(411)), NodeID: Ptr("IT_kwDNAd3NAZs"), Name: Ptr("Bug"), Description: Ptr("An unexpected problem or behavior"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178002), + UpdatedAt: refTimestamp(1136178003), }, } if !cmp.Equal(issueTypes, want) { @@ -102,8 +102,8 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { "node_id": "IT_kwDNAd3NAZo", "name": "Epic", "description": "An issue type for a multi-week tracking of work", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }`) }) @@ -117,8 +117,8 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { NodeID: Ptr("IT_kwDNAd3NAZo"), Name: Ptr("Epic"), Description: Ptr("An issue type for a multi-week tracking of work"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(issueType, want) { @@ -160,8 +160,8 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { "node_id": "IT_kwDNAd3NAZo", "name": "Epic", "description": "An issue type for a multi-week tracking of work", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }`) }) @@ -175,8 +175,8 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { NodeID: Ptr("IT_kwDNAd3NAZo"), Name: Ptr("Epic"), Description: Ptr("An issue type for a multi-week tracking of work"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), } if !cmp.Equal(issueType, want) { From dea9370481acda2ce6279216fcd3a4f0fcb48807 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:07:51 -0400 Subject: [PATCH 25/34] Fix github/orgs_members_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/orgs_members_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 89592c0fea3..576620a77ec 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -765,8 +765,8 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { "node_id":"MDQ6VXNlcjE=", "email":"octocat@github.com", "role":"direct_member", - "created_at":`+referenceTimeStr+`, - "failed_at":`+referenceTimeStr+`, + "created_at":`+refTimeStr(1136178000)+`, + "failed_at":`+refTimeStr(1136178001)+`, "failed_reason":"the reason", "inviter":{ "login":"other_user", @@ -808,9 +808,9 @@ func TestOrganizationsService_ListFailedOrgInvitations(t *testing.T) { NodeID: Ptr("MDQ6VXNlcjE="), Email: Ptr("octocat@github.com"), Role: Ptr("direct_member"), - FailedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + FailedAt: refTimestamp(1136178001), FailedReason: Ptr("the reason"), - CreatedAt: &referenceTimestamp, Inviter: &User{ Login: Ptr("other_user"), ID: Ptr(int64(1)), From 75857733cd820725fd987b8424b879d8cdb96f4b Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:37:43 -0400 Subject: [PATCH 26/34] Fix github/orgs_organization_roles_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/orgs_organization_roles_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/github/orgs_organization_roles_test.go b/github/orgs_organization_roles_test.go index 35e5769a6d5..e1300ad5356 100644 --- a/github/orgs_organization_roles_test.go +++ b/github/orgs_organization_roles_test.go @@ -36,8 +36,8 @@ func TestOrganizationsService_ListRoles(t *testing.T) { "location": "l", "email": "e" }, - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "source": "Organization", "base_role": "admin" } @@ -70,8 +70,8 @@ func TestOrganizationsService_ListRoles(t *testing.T) { Location: Ptr("l"), Email: Ptr("e"), }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Source: Ptr("Organization"), BaseRole: Ptr("admin"), }, @@ -108,8 +108,8 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { "name": "all_repo_read", "description": "Grants read access to all repositories in the organization.", "permissions": [], - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "source": "Predefined", "base_role": "read" }`) @@ -127,8 +127,8 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { Name: Ptr("all_repo_read"), Description: Ptr("Grants read access to all repositories in the organization."), Permissions: []string{}, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Source: Ptr("Predefined"), BaseRole: Ptr("read"), } @@ -149,8 +149,8 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { "read_organization_custom_repo_role", "write_organization_custom_org_role" ], - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "source": "Organization", "base_role": null }`) @@ -170,8 +170,8 @@ func TestOrganizationsService_GetOrgRole(t *testing.T) { "read_organization_custom_repo_role", "write_organization_custom_org_role", }, - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Source: Ptr("Organization"), BaseRole: nil, } From bb0db51ad43078853aaad8cf41996fbaa1b1e25b Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:38:42 -0400 Subject: [PATCH 27/34] Fix github/orgs_personal_access_tokens_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/orgs_personal_access_tokens_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github/orgs_personal_access_tokens_test.go b/github/orgs_personal_access_tokens_test.go index 1607e1460a5..b2d82399cbb 100644 --- a/github/orgs_personal_access_tokens_test.go +++ b/github/orgs_personal_access_tokens_test.go @@ -62,9 +62,9 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokens(t *testing.T) "metadata": "read" } }, - "access_granted_at": `+referenceTimeStr+`, + "access_granted_at": `+refTimeStr(1136178000)+`, "token_expired": false, - "token_expires_at": `+referenceTimeStr+`, + "token_expires_at": `+refTimeStr(1136178001)+`, "token_last_used_at": null } ]`) @@ -111,9 +111,9 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokens(t *testing.T) Org: map[string]string{"members": "read"}, Repo: map[string]string{"metadata": "read"}, }, - AccessGrantedAt: &referenceTimestamp, + AccessGrantedAt: refTimestamp(1136178000), TokenExpired: Ptr(false), - TokenExpiresAt: &referenceTimestamp, + TokenExpiresAt: refTimestamp(1136178001), TokenLastUsedAt: nil, }, } @@ -209,11 +209,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokenRequests(t *test "metadata": "read" } }, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "token_id": 11579703, "token_name": "testFineGrained", "token_expired": false, - "token_expires_at": `+referenceTimeStr+`, + "token_expires_at": `+refTimeStr(1136178001)+`, "token_last_used_at": null } ]`) @@ -261,11 +261,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokenRequests(t *test Permissions: PersonalAccessTokenPermissions{ Repo: map[string]string{"metadata": "read"}, }, - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), TokenID: 11579703, TokenName: "testFineGrained", TokenExpired: false, - TokenExpiresAt: &referenceTimestamp, + TokenExpiresAt: refTimestamp(1136178001), TokenLastUsedAt: nil, }, } From 25988b5a2d9fd2ef64eb29c7639fac6a931705db Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:39:41 -0400 Subject: [PATCH 28/34] Fix github/private_registries_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/private_registries_test.go | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/github/private_registries_test.go b/github/private_registries_test.go index 0c72c5a0c4f..ec0500ef7dd 100644 --- a/github/private_registries_test.go +++ b/github/private_registries_test.go @@ -31,8 +31,8 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T "name": "MAVEN_REPOSITORY_SECRET", "registry_type": "maven_repository", "username": "monalisa", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "visibility": "selected" } ] @@ -53,8 +53,8 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), Username: Ptr("monalisa"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Visibility: Ptr(PrivateRegistryVisibilitySelected), }, }, @@ -109,8 +109,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T "username": "monalisa", "visibility": "selected", "selected_repository_ids": [1, 2, 3], - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }`) }) @@ -124,8 +124,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), Username: Ptr("monalisa"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Visibility: Ptr(PrivateRegistryVisibilitySelected), SelectedRepositoryIDs: []int64{1, 2, 3}, } @@ -173,8 +173,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test "registry_type": "maven_repository", "visibility": "selected", "selected_repository_ids": [1, 2, 3], - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }`) }) @@ -187,8 +187,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test want := &PrivateRegistry{ Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Visibility: Ptr(PrivateRegistryVisibilitySelected), SelectedRepositoryIDs: []int64{1, 2, 3}, } @@ -249,8 +249,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t "name": "NPM_REGISTRY_SECRET", "registry_type": "npm_registry", "visibility": "private", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+` + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+` }`) }) @@ -263,8 +263,8 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t want := &PrivateRegistry{ Name: Ptr("NPM_REGISTRY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeNpmRegistry), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Visibility: Ptr(PrivateRegistryVisibilityPrivate), } if diff := cmp.Diff(want, privateRegistry); diff != "" { @@ -324,8 +324,8 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) { "name": "MAVEN_REPOSITORY_SECRET", "registry_type": "maven_repository", "username": "monalisa", - "created_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, "visibility": "selected" }`) }) @@ -339,8 +339,8 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) { Name: Ptr("MAVEN_REPOSITORY_SECRET"), RegistryType: Ptr(PrivateRegistryTypeMavenRepository), Username: Ptr("monalisa"), - CreatedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), Visibility: Ptr(PrivateRegistryVisibilitySelected), } if diff := cmp.Diff(want, privateRegistry); diff != "" { From b70e6aa24c8e392b4d8454b3aca52c239f4f93d5 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:42:25 -0400 Subject: [PATCH 29/34] Fix github/repos_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/repos_test.go b/github/repos_test.go index 2951b5634eb..cd206c654e1 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -4432,8 +4432,8 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) testMethod(t, r, "GET") testFormValues(t, r, values{ "direction": "desc", - "before": referenceTimeStr, - "after": referenceTimeStr, + "before": refTimeStr(1136178000), + "after": refTimeStr(1136178001), "ref": "refs/heads/main", "actor": "testuser1", "time_period": "day", @@ -4476,8 +4476,8 @@ func TestRepositoriesService_ListRepositoryActivities_withOptions(t *testing.T) opts := &ListRepositoryActivityOptions{ Direction: "desc", - Before: referenceTimeStr, - After: referenceTimeStr, + Before: refTimeStr(1136178000), + After: refTimeStr(1136178001), Ref: "refs/heads/main", Actor: "testuser1", TimePeriod: "day", From 8f67dd1b522e76cb8156111f2424f607689cbf44 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:43:37 -0400 Subject: [PATCH 30/34] Fix github/scim_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/scim_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github/scim_test.go b/github/scim_test.go index 6ca1d323653..a26a3cb17c1 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -52,8 +52,8 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { "active": true, "meta": { "resourceType": "User", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, + "created": ` + refTimeStr(1136178000) + `, + "lastModified": ` + refTimeStr(1136178001) + `, "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75" } } @@ -82,8 +82,8 @@ func TestSCIMService_ListSCIMProvisionedIdentities(t *testing.T) { ID: Ptr("5fc0c238-1112-11e8-8e45-920c87bdbd75"), Meta: &SCIMMeta{ ResourceType: Ptr("User"), - Created: &referenceTimestamp, - LastModified: &referenceTimestamp, + Created: refTimestamp(1136178000), + LastModified: refTimestamp(1136178001), Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75"), }, UserName: "octocat@github.com", @@ -207,8 +207,8 @@ func TestSCIMService_GetSCIMProvisioningInfoForUser(t *testing.T) { "active": true, "meta": { "resourceType": "User", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, + "created": ` + refTimeStr(1136178000) + `, + "lastModified": ` + refTimeStr(1136178001) + `, "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32" } }`)) @@ -224,8 +224,8 @@ func TestSCIMService_GetSCIMProvisioningInfoForUser(t *testing.T) { ID: Ptr("edefdfedf-050c-11e7-8d32"), Meta: &SCIMMeta{ ResourceType: Ptr("User"), - Created: &referenceTimestamp, - LastModified: &referenceTimestamp, + Created: refTimestamp(1136178000), + LastModified: refTimestamp(1136178001), Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"), }, UserName: "mona.octocat@okta.example.com", From 7b33125b4e3b2e0affbfe6741c6ef472a346e900 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:45:07 -0400 Subject: [PATCH 31/34] Fix github/secret_scanning_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/secret_scanning_test.go | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 1b77a4202e7..852e3da073f 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -23,7 +23,7 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -52,7 +52,7 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) { want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -97,7 +97,7 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -121,7 +121,7 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) { want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -161,7 +161,7 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -187,7 +187,7 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) { want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -227,7 +227,7 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) { fmt.Fprint(w, `[{ "number": 1, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -251,7 +251,7 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) { want := []*SecretScanningAlert{ { Number: Ptr(1), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -290,7 +290,7 @@ func TestSecretScanningService_GetAlert(t *testing.T) { fmt.Fprint(w, `{ "number": 1, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", @@ -312,7 +312,7 @@ func TestSecretScanningService_GetAlert(t *testing.T) { want := &SecretScanningAlert{ Number: Ptr(1), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), @@ -352,14 +352,14 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { testJSONBody(t, r, opts) fmt.Fprint(w, `{ "number": 1, - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1", "html_url": "https://github.com/o/r/security/secret-scanning/1", "locations_url": "https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations", "state": "resolved", "resolution": "used_in_tests", "resolution_comment": "resolution comment", - "resolved_at": `+referenceTimeStr+`, + "resolved_at": `+refTimeStr(1136178001)+`, "resolved_by": null, "secret_type": "mailchimp_api_key", "secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2" @@ -374,14 +374,14 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { want := &SecretScanningAlert{ Number: Ptr(1), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), URL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1"), HTMLURL: Ptr("https://github.com/o/r/security/secret-scanning/1"), LocationsURL: Ptr("https://api.github.com/repos/o/r/secret-scanning/alerts/1/locations"), State: Ptr("resolved"), Resolution: Ptr("used_in_tests"), ResolutionComment: Ptr("resolution comment"), - ResolvedAt: &referenceTimestamp, + ResolvedAt: refTimestamp(1136178001), ResolvedBy: nil, SecretType: Ptr("mailchimp_api_key"), Secret: Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"), @@ -483,7 +483,7 @@ func TestSecretScanningService_CreatePushProtectionBypass(t *testing.T) { testJSONBody(t, r, opts) fmt.Fprint(w, `{ "reason": "valid reason", - "expire_at": `+referenceTimeStr+`, + "expire_at": `+refTimeStr(1136178000)+`, "token_type": "github_token" }`) }) @@ -497,7 +497,7 @@ func TestSecretScanningService_CreatePushProtectionBypass(t *testing.T) { want := &PushProtectionBypass{ Reason: "valid reason", - ExpireAt: &referenceTimestamp, + ExpireAt: refTimestamp(1136178000), TokenType: "github_token", } @@ -529,8 +529,8 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { { "type": "incremental", "status": "success", - "completed_at": `+referenceTimeStr+`, - "started_at": `+referenceTimeStr+` + "completed_at": `+refTimeStr(1136178000)+`, + "started_at": `+refTimeStr(1136178001)+` } ], "backfill_scans": [], @@ -540,7 +540,7 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { "type": "custom_backfill", "status": "in_progress", "completed_at": null, - "started_at": `+referenceTimeStr+`, + "started_at": `+refTimeStr(1136178002)+`, "pattern_slug": "my-custom-pattern", "pattern_scope": "organization" } @@ -557,13 +557,13 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) { want := &SecretScanningScanHistory{ IncrementalScans: []*SecretsScan{ - {Type: "incremental", Status: "success", CompletedAt: &referenceTimestamp, StartedAt: &referenceTimestamp}, + {Type: "incremental", Status: "success", CompletedAt: refTimestamp(1136178000), StartedAt: refTimestamp(1136178001)}, }, BackfillScans: []*SecretsScan{}, PatternUpdateScans: []*SecretsScan{}, CustomPatternBackfillScans: []*CustomPatternBackfillScan{ { - SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: &referenceTimestamp}, + SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: refTimestamp(1136178002)}, PatternSlug: Ptr("my-custom-pattern"), PatternScope: Ptr("organization"), }, From 90e62023ef596df3324c9f73a47c37562853ada8 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:46:25 -0400 Subject: [PATCH 32/34] Fix github/security_advisories_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/security_advisories_test.go | 56 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index 7332e3965fa..a5135a76b06 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -86,9 +86,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork(t *testing.T) { "name": "repo-ghsa-xxxx-xxxx-xxxx", "full_name": "owner/repo-ghsa-xxxx-xxxx-xxxx", "default_branch": "master", - "created_at": `+referenceTimeStr+`, - "pushed_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "pushed_at": `+refTimeStr(1136178001)+`, + "updated_at": `+refTimeStr(1136178002)+`, "html_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx", "clone_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", "git_url": "git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", @@ -195,9 +195,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork(t *testing.T) { Name: Ptr("repo-ghsa-xxxx-xxxx-xxxx"), FullName: Ptr("owner/repo-ghsa-xxxx-xxxx-xxxx"), DefaultBranch: Ptr("master"), - CreatedAt: &referenceTimestamp, - PushedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + PushedAt: refTimestamp(1136178001), + UpdatedAt: refTimestamp(1136178002), HTMLURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), CloneURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), GitURL: Ptr("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), @@ -322,9 +322,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork_deferred(t *testin "name": "repo-ghsa-xxxx-xxxx-xxxx", "full_name": "owner/repo-ghsa-xxxx-xxxx-xxxx", "default_branch": "master", - "created_at": `+referenceTimeStr+`, - "pushed_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, + "pushed_at": `+refTimeStr(1136178001)+`, + "updated_at": `+refTimeStr(1136178002)+`, "html_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx", "clone_url": "https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", "git_url": "git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git", @@ -431,9 +431,9 @@ func TestSecurityAdvisoriesService_CreateTemporaryPrivateFork_deferred(t *testin Name: Ptr("repo-ghsa-xxxx-xxxx-xxxx"), FullName: Ptr("owner/repo-ghsa-xxxx-xxxx-xxxx"), DefaultBranch: Ptr("master"), - CreatedAt: &referenceTimestamp, - PushedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), + PushedAt: refTimestamp(1136178001), + UpdatedAt: refTimestamp(1136178002), HTMLURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx"), CloneURL: Ptr("https://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), GitURL: Ptr("git://github.com/owner/repo-ghsa-xxxx-xxxx-xxxx.git"), @@ -773,10 +773,10 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { } ], "references": ["https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"], - "published_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, - "github_reviewed_at": `+referenceTimeStr+`, - "nvd_published_at": `+referenceTimeStr+`, + "published_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, + "github_reviewed_at": `+refTimeStr(1136178002)+`, + "nvd_published_at": `+refTimeStr(1136178003)+`, "withdrawn_at": null, "vulnerabilities": [ { @@ -857,8 +857,8 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { Value: Ptr("CVE-xoxo-1234"), }, }, - PublishedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + PublishedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), WithdrawnAt: nil, CVSS: &AdvisoryCVSS{ VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), @@ -886,8 +886,8 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { RepositoryAdvisoryURL: Ptr("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), Type: Ptr("reviewed"), SourceCodeLocation: Ptr("https://github.com/project/a-package"), - GithubReviewedAt: &referenceTimestamp, - NVDPublishedAt: &referenceTimestamp, + GithubReviewedAt: refTimestamp(1136178002), + NVDPublishedAt: refTimestamp(1136178003), Credits: []*Credit{ { User: &User{ @@ -957,10 +957,10 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { } ], "references": ["https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"], - "published_at": `+referenceTimeStr+`, - "updated_at": `+referenceTimeStr+`, - "github_reviewed_at": `+referenceTimeStr+`, - "nvd_published_at": `+referenceTimeStr+`, + "published_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, + "github_reviewed_at": `+refTimeStr(1136178002)+`, + "nvd_published_at": `+refTimeStr(1136178003)+`, "withdrawn_at": null, "vulnerabilities": [ { @@ -1037,8 +1037,8 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { Value: Ptr("CVE-xoxo-1234"), }, }, - PublishedAt: &referenceTimestamp, - UpdatedAt: &referenceTimestamp, + PublishedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), WithdrawnAt: nil, CVSS: &AdvisoryCVSS{ VectorString: Ptr("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"), @@ -1055,8 +1055,8 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { Type: Ptr("reviewed"), SourceCodeLocation: Ptr("https://github.com/project/a-package"), References: []string{"https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"}, - GithubReviewedAt: &referenceTimestamp, - NVDPublishedAt: &referenceTimestamp, + GithubReviewedAt: refTimestamp(1136178002), + NVDPublishedAt: refTimestamp(1136178003), Vulnerabilities: []*GlobalSecurityVulnerability{ { From 96852cb5e637622e426bae21bb1c4ee91728f2c9 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:47:03 -0400 Subject: [PATCH 33/34] Fix github/teams_discussion_comments_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/teams_discussion_comments_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index b68712d1866..c25ba0f12d9 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -65,13 +65,13 @@ func TestTeamsService_ListComments(t *testing.T) { "body": "comment", "body_html": "

comment

", "body_version": "version", - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "last_edited_at": null, "discussion_url": "https://api.github.com/teams/2/discussions/3", "html_url": "https://github.com/orgs/1/teams/2/discussions/3/comments/4", "node_id": "node", "number": 4, - "updated_at": `+referenceTimeStr+`, + "updated_at": `+refTimeStr(1136178001)+`, "url": "https://api.github.com/teams/2/discussions/3/comments/4" } ]`) @@ -101,13 +101,13 @@ func TestTeamsService_ListComments(t *testing.T) { Body: Ptr("comment"), BodyHTML: Ptr("

comment

"), BodyVersion: Ptr("version"), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), LastEditedAt: nil, DiscussionURL: Ptr("https://api.github.com/teams/2/discussions/3"), HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3/comments/4"), NodeID: Ptr("node"), Number: Ptr(4), - UpdatedAt: &referenceTimestamp, + UpdatedAt: refTimestamp(1136178001), URL: Ptr("https://api.github.com/teams/2/discussions/3/comments/4"), }, } From c73aa69506018bebb56cb3faa306fdbb941c0995 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:47:45 -0400 Subject: [PATCH 34/34] Fix github/teams_discussions_test.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/teams_discussions_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index ce25c7460ec..11be8d3ddda 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -50,7 +50,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { "body_version": "version", "comments_count": 1, "comments_url": "https://api.github.com/teams/2/discussions/3/comments", - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "last_edited_at": null, "html_url": "https://github.com/orgs/1/teams/2/discussions/3", "node_id": "node", @@ -59,7 +59,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { "private": false, "team_url": "https://api.github.com/teams/2", "title": "test", - "updated_at": `+referenceTimeStr+`, + "updated_at": `+refTimeStr(1136178001)+`, "url": "https://api.github.com/teams/2/discussions/3" } ]`) @@ -96,7 +96,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { BodyVersion: Ptr("version"), CommentsCount: Ptr(1), CommentsURL: Ptr("https://api.github.com/teams/2/discussions/3/comments"), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), LastEditedAt: nil, HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3"), NodeID: Ptr("node"), @@ -105,7 +105,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { Private: Ptr(false), TeamURL: Ptr("https://api.github.com/teams/2"), Title: Ptr("test"), - UpdatedAt: &referenceTimestamp, + UpdatedAt: refTimestamp(1136178001), URL: Ptr("https://api.github.com/teams/2/discussions/3"), }, } @@ -165,7 +165,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { "body_version": "version", "comments_count": 1, "comments_url": "https://api.github.com/teams/2/discussions/3/comments", - "created_at": `+referenceTimeStr+`, + "created_at": `+refTimeStr(1136178000)+`, "last_edited_at": null, "html_url": "https://github.com/orgs/1/teams/2/discussions/3", "node_id": "node", @@ -174,7 +174,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { "private": false, "team_url": "https://api.github.com/teams/2", "title": "test", - "updated_at": `+referenceTimeStr+`, + "updated_at": `+refTimeStr(1136178001)+`, "url": "https://api.github.com/teams/2/discussions/3" } ]`) @@ -211,7 +211,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { BodyVersion: Ptr("version"), CommentsCount: Ptr(1), CommentsURL: Ptr("https://api.github.com/teams/2/discussions/3/comments"), - CreatedAt: &referenceTimestamp, + CreatedAt: refTimestamp(1136178000), LastEditedAt: nil, HTMLURL: Ptr("https://github.com/orgs/1/teams/2/discussions/3"), NodeID: Ptr("node"), @@ -220,7 +220,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { Private: Ptr(false), TeamURL: Ptr("https://api.github.com/teams/2"), Title: Ptr("test"), - UpdatedAt: &referenceTimestamp, + UpdatedAt: refTimestamp(1136178001), URL: Ptr("https://api.github.com/teams/2/discussions/3"), }, }