-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/github: fix parsing of times
The format for parsing times differed from the one used by the GitHub API. The error was silently lost. Instead, a zero time was returned, meaning all issues and comments appeared to be before the commentfix.Fixer's cutoff and were not processed. This CL should fix the problem for subsequent issues, but we still have to go back and manually fix the ones that were missed somehow. Besides using the right format, and testing it against actual values from GH, also panic on error so gaby fails fast. It was only because Cherry was observant that this was noticed at all. For #54. Change-Id: Ib639dd68cae950ccba1af8e798ea6ae2c9ba5e19 Reviewed-on: https://go-review.googlesource.com/c/oscar/+/629797 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
- Loading branch information
Showing
2 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package github | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestMustParseTime(t *testing.T) { | ||
for _, tc := range []struct { | ||
in string | ||
want time.Time | ||
}{ | ||
{"", time.Time{}}, | ||
{"2015-08-05T01:55:29Z", time.Date(2015, 8, 5, 1, 55, 29, 0, time.UTC)}, | ||
{"2024-11-11T18:41:58Z", time.Date(2024, 11, 11, 18, 41, 58, 0, time.UTC)}, | ||
} { | ||
got := mustParseTime(tc.in) | ||
if !got.Equal(tc.want) { | ||
t.Errorf("%q: got %s, want %s", tc.in, got, tc.want) | ||
} | ||
} | ||
} |