MCPcopy Index your code
hub / github.com/google/go-github / TestParseTokenExpiration

Function TestParseTokenExpiration

github/github_test.go:4458–4500  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4456}
4457
4458func TestParseTokenExpiration(t *testing.T) {
4459 t.Parallel()
4460 tests := []struct {
4461 header string
4462 want Timestamp
4463 }{
4464 {
4465 header: "",
4466 want: Timestamp{},
4467 },
4468 {
4469 header: "this is a garbage",
4470 want: Timestamp{},
4471 },
4472 {
4473 header: "2021-09-03 02:34:04 UTC",
4474 want: Timestamp{time.Date(2021, time.September, 3, 2, 34, 4, 0, time.UTC)},
4475 },
4476 {
4477 header: "2021-09-03 14:34:04 UTC",
4478 want: Timestamp{time.Date(2021, time.September, 3, 14, 34, 4, 0, time.UTC)},
4479 },
4480 // Some tokens include the timezone offset instead of the timezone.
4481 // https://github.com/google/go-github/issues/2649
4482 {
4483 header: "2023-04-26 20:23:26 +0200",
4484 want: Timestamp{time.Date(2023, time.April, 26, 18, 23, 26, 0, time.UTC)},
4485 },
4486 }
4487
4488 for _, tt := range tests {
4489 res := &http.Response{
4490 Request: &http.Request{},
4491 Header: http.Header{},
4492 }
4493
4494 res.Header.Set(headerTokenExpiration, tt.header)
4495 exp := parseTokenExpiration(res)
4496 if !exp.Equal(tt.want) {
4497 t.Errorf("parseTokenExpiration of %q\nreturned %#v\n want %#v", tt.header, exp, tt.want)
4498 }
4499 }
4500}
4501
4502func TestClientCopy_leak_transport(t *testing.T) {
4503 t.Parallel()

Callers

nothing calls this directly

Calls 2

parseTokenExpirationFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…