Skip to content

Commit ed4d3cd

Browse files
author
Stephen Gutekanst
committed
testdata: update to reflect green -> yellow change
1 parent e0dd4e2 commit ed4d3cd

4 files changed

Lines changed: 68 additions & 68 deletions

File tree

cmd/src/testdata/search_formatting/basic-commit.want.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(https://sourcegraph.com/github.com/golang/oauth2/-/commit/30b72dfc067246f4fa261c8890160b889fdd4b29)
44
github.com/golang/oauth2 › Tim Cooper "oauth2: close request body if errors occur before base RoundTripper is invoked" (2 months ago)
55
--------------------------------------------------------------------------------
6-
 oauth2: close request body if errors occur before base RoundTripper is invoked
6+
 oauth2: close request body if errors occur before base RoundTripper is invoked
77

88
Fixes golang/oauth#269
99

@@ -16,8 +16,8 @@
1616
--------------------------------------------------------------------------------
1717
 internal: remove RegisterContextClientFunc
1818

19-
This function added a totally unused error path, since the only call
20-
site is for App Engine, which cannot produce an error.
19+
This function added a totally unused error path, since the only call
20+
site is for App Engine, which cannot produce an error.
2121

2222
Change-Id: I86277ab4ff96e7bd140c53c5a114a338716668e3
2323
Reviewed-on: https://go-review.googlesource.com/85935
@@ -26,13 +26,13 @@
2626
(https://sourcegraph.com/github.com/golang/oauth2/-/commit/ee2bad97a97122079f2a3d0dce09330f085b36a0)
2727
github.com/golang/oauth2 › Ross Light "internal: return error if no access_token present in server response" (7 months ago)
2828
--------------------------------------------------------------------------------
29-
 internal: return error if no access_token present in server response
29+
 internal: return error if no access_token present in server response
3030

3131
This behavior and test was introduced in 0ae3d4edc99f765dc1513a9605aa96e82877a20a.
3232
It is not consistent with the other test introduced in the same commit,
33-
where an incorrectly typed access_token does produce an error. Since a
33+
where an incorrectly typed access_token does produce an error. Since a
3434
*Token with a blank AccessToken is invalid, it is allowing an invalid
35-
token to be returned without error.
35+
token to be returned without error.
3636

3737
Cleans up some tests responding with invalid data.
3838

cmd/src/testdata/search_formatting/basic-diff.want.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,49 @@
88
--- transport_test.go
99
+++ transport_test.go
1010
@@ -3,0 +4,2 @@ import (
11-
+ "errors"
11+
+ "errors"
1212
+ "io"
1313
@@ -29,0 +33,6 @@ func TestTransportNilTokenSource(t *testing.T) {
1414
+ CloseCount int
15-
+ ReadErr error
15+
+ ReadErr error
1616
+}
1717
+
18-
+func (r *readCloseCounter) Read(b []byte) (int, error) {
18+
+func (r *readCloseCounter) Read(b []byte) (int, error) {
1919
+ return 0, r.ReadErr
2020
@@ -29,0 +40,3 @@ func TestTransportNilTokenSource(t *testing.T) {
2121
+
22-
+func (r *readCloseCounter) Close() error {
22+
+func (r *readCloseCounter) Close() error {
2323
+ r.CloseCount++
2424

2525
--------------------------------------------------------------------------------
2626
(https://sourcegraph.com/github.com/golang/oauth2/-/commit/088f8e1d436e8d636f13cd83a345b3d6ff2f04ae)
27-
github.com/golang/oauth2 › Guillaume J. Charmes "oauth2: Add support for custom params in Exchange" (2 months ago)
27+
github.com/golang/oauth2 › Guillaume J. Charmes "oauth2: Add support for custom params in Exchange" (3 months ago)
2828
--------------------------------------------------------------------------------
2929
 diff --git oauth2.go oauth2.go
3030
index 10299d2..16775d0 100644
3131
--- oauth2.go
3232
+++ oauth2.go
3333
@@ -189,1 +191,1 @@ func (c *Config) PasswordCredentialsToken(ctx context.Context, username, passwor
34-
-func (c *Config) Exchange(ctx context.Context, code string) (*Token, error) {
34+
-func (c *Config) Exchange(ctx context.Context, code string) (*Token, error) {
3535
+//
3636
@@ -190,0 +193,2 @@ func (c *Config) PasswordCredentialsToken(ctx context.Context, username, passwor
3737
+// See https://www.oauth.com/oauth2-servers/pkce/ for more info.
38-
+func (c *Config) Exchange(ctx context.Context, code string, opts ...AuthCodeOption) (*Token, error) {
38+
+func (c *Config) Exchange(ctx context.Context, code string, opts ...AuthCodeOption) (*Token, error) {
3939
diff --git oauth2_test.go oauth2_test.go
4040
index 847160f..ef12ebc 100644
4141
--- oauth2_test.go
4242
+++ oauth2_test.go
4343
@@ -137,0 +140,3 @@ func TestExchangeRequest(t *testing.T) {
4444
+ if r.URL.String() != "/token" {
45-
+ t.Errorf("Unexpected exchange request URL, %v is found.", r.URL)
45+
+ t.Errorf("Unexpected exchange request URL, %v is found.", r.URL)
4646
+ }
4747
@@ -137,0 +144,3 @@ func TestExchangeRequest(t *testing.T) {
4848
+ if headerAuth != "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" {
49-
+ t.Errorf("Unexpected authorization header, %v is found.", headerAuth)
49+
+ t.Errorf("Unexpected authorization header, %v is found.", headerAuth)
5050
+ }
5151
@@ -137,0 +148,3 @@ func TestExchangeRequest(t *testing.T) {
5252
+ if headerContentType != "application/x-www-form-urlencoded" {
53-
+ t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType)
53+
+ t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType)
5454
+ }
5555

5656
--------------------------------------------------------------------------------
@@ -64,18 +64,18 @@
6464
+++ jira/jira.go
6565
@@ -0,0 +79,3 @@
6666
+
67-
+func (js jwtSource) Token() (*oauth2.Token, error) {
67+
+func (js jwtSource) Token() (*oauth2.Token, error) {
6868
+ exp := time.Duration(59) * time.Second
6969
@@ -0,0 +113,3 @@
7070
+ if err != nil {
71-
+ return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err)
71+
+ return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err)
7272
+ }
7373
@@ -0,0 +118,6 @@
7474
+ if err != nil {
75-
+ return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err)
75+
+ return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err)
7676
+ }
7777
+ if c := resp.StatusCode; c < 200 || c > 299 {
78-
+ return nil, fmt.Errorf("oauth2: cannot fetch token: %v\nResponse: %s", resp.Status, body)
78+
+ return nil, fmt.Errorf("oauth2: cannot fetch token: %v\nResponse: %s", resp.Status, body)
7979
+ }
8080
diff --git jira/jira_test.go jira/jira_test.go
8181
new file mode 100644
@@ -84,24 +84,24 @@
8484
+++ jira/jira_test.go
8585
@@ -0,0 +49,7 @@ ... +2
8686
+ if !tok.Valid() {
87-
+ t.Errorf("got invalid token: %v", tok)
87+
+ t.Errorf("got invalid token: %v", tok)
8888
+ }
8989
+ if got, want := tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c"; got != want {
90-
+ t.Errorf("access token = %q; want %q", got, want)
90+
+ t.Errorf("access token = %q; want %q", got, want)
9191
+ }
9292
+ if got, want := tok.TokenType, "Bearer"; got != want {
9393
@@ -0,0 +86,7 @@ ... +1
9494
+ if tok.Valid() {
95-
+ t.Errorf("got invalid token: %v", tok)
95+
+ t.Errorf("got invalid token: %v", tok)
9696
+ }
9797
+ if got, want := tok.AccessToken, ""; got != want {
98-
+ t.Errorf("access token = %q; want %q", got, want)
98+
+ t.Errorf("access token = %q; want %q", got, want)
9999
+ }
100100
+ if got, want := tok.TokenType, "Bearer"; got != want {
101101
@@ -0,0 +116,5 @@
102102
+ if err == nil {
103-
+ t.Error("got a token; expected error")
103+
+ t.Error("got a token; expected error")
104104
+ if got, want := tok.AccessToken, ""; got != want {
105-
+ t.Errorf("access token = %q; want %q", got, want)
105+
+ t.Errorf("access token = %q; want %q", got, want)
106106
+ }
107107

cmd/src/testdata/search_formatting/basic.want.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@
33
(https://sourcegraph.com/github.com/golang/oauth2/-/blob/clientcredentials/clientcredentials.go)
44
github.com/golang/oauth2 › clientcredentials.go (5 matches)
55
--------------------------------------------------------------------------------
6-
  50 | func (c *Config) Token(ctx context.Context) (*oauth2.Token, error) {
6+
  50 | func (c *Config) Token(ctx context.Context) (*oauth2.Token, error) {
77
 ------------------------------------------------------------------------------
8-
  82 | func (c *tokenSource) Token() (*oauth2.Token, error) {
8+
  82 | func (c *tokenSource) Token() (*oauth2.Token, error) {
99
 ------------------------------------------------------------------------------
10-
  91 |  return nil, fmt.Errorf("oauth2: cannot overwrite parameter %q", k)
10+
  91 |  return nil, fmt.Errorf("oauth2: cannot overwrite parameter %q", k)
1111
 ------------------------------------------------------------------------------
12-
  97 |  if rErr, ok := err.(*internal.RetrieveError); ok {
13-
 98 |  return nil, (*oauth2.RetrieveError)(rErr)
12+
  97 |  if rErr, ok := err.(*internal.RetrieveError); ok {
13+
 98 |  return nil, (*oauth2.RetrieveError)(rErr)
1414
--------------------------------------------------------------------------------
1515
(https://sourcegraph.com/github.com/golang/oauth2/-/blob/clientcredentials/clientcredentials_test.go)
1616
github.com/golang/oauth2 › clientcredentials_test.go (13 matches)
1717
--------------------------------------------------------------------------------
18-
  27 |  rt func(req *http.Request) (resp *http.Response, err error)
18+
  27 |  rt func(req *http.Request) (resp *http.Response, err error)
1919
 ------------------------------------------------------------------------------
20-
  30 | func (t *mockTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
20+
  30 | func (t *mockTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
2121
 ------------------------------------------------------------------------------
22-
  37 |  t.Errorf("authenticate client request URL = %q; want %q", r.URL, "/token")
22+
  37 |  t.Errorf("authenticate client request URL = %q; want %q", r.URL, "/token")
2323
 ------------------------------------------------------------------------------
24-
  41 |  t.Errorf("Unexpected authorization header, %v is found.", headerAuth)
24+
  41 |  t.Errorf("Unexpected authorization header, %v is found.", headerAuth)
2525
 ------------------------------------------------------------------------------
26-
  44 |  t.Errorf("Content-Type header = %q; want %q", got, want)
26+
  44 |  t.Errorf("Content-Type header = %q; want %q", got, want)
2727
 ------------------------------------------------------------------------------
28-
  51 |  t.Errorf("failed reading request body: %s.", err)
28+
  51 |  t.Errorf("failed reading request body: %s.", err)
2929
 ------------------------------------------------------------------------------
30-
  54 |  t.Errorf("payload = %q; want %q", string(body), "grant_type=client_credentials&scope=scope1+scope2")
30+
  54 |  t.Errorf("payload = %q; want %q", string(body), "grant_type=client_credentials&scope=scope1+scope2")
3131
 ------------------------------------------------------------------------------
32-
  63 |  t.Error(err)
32+
  63 |  t.Error(err)
3333
 ------------------------------------------------------------------------------
34-
  69 |  t.Errorf("Access token = %q; want %q", tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c")
34+
  69 |  t.Errorf("Access token = %q; want %q", tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c")
3535
 ------------------------------------------------------------------------------
36-
  72 |  t.Errorf("token type = %q; want %q", tok.TokenType, "bearer")
36+
  72 |  t.Errorf("token type = %q; want %q", tok.TokenType, "bearer")
3737
 ------------------------------------------------------------------------------
38-
  82 |  t.Errorf("Unexpected token refresh request URL, %v is found.", r.URL)
38+
  82 |  t.Errorf("Unexpected token refresh request URL, %v is found.", r.URL)
3939
 ------------------------------------------------------------------------------
40-
  86 |  t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType)
40+
  86 |  t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType)
4141
 ------------------------------------------------------------------------------
42-
  90 |  t.Errorf("Unexpected refresh token payload, %v is found.", string(body))
42+
  90 |  t.Errorf("Unexpected refresh token payload, %v is found.", string(body))
4343
--------------------------------------------------------------------------------
4444
(https://sourcegraph.com/github.com/golang/oauth2/-/blob/google/appengine.go)
4545
github.com/golang/oauth2 › appengine.go (2 matches)
4646
--------------------------------------------------------------------------------
47-
  21 | var appengineTokenFunc func(c context.Context, scopes ...string) (token string, expiry time.Time, err error)
47+
  21 | var appengineTokenFunc func(c context.Context, scopes ...string) (token string, expiry time.Time, err error)
4848
 ------------------------------------------------------------------------------
49-
  62 | func (ts *appEngineTokenSource) Token() (*oauth2.Token, error) {
49+
  62 | func (ts *appEngineTokenSource) Token() (*oauth2.Token, error) {
5050
--------------------------------------------------------------------------------
5151
(https://sourcegraph.com/github.com/golang/oauth2/-/blob/google/go19.go)
5252
github.com/golang/oauth2 › go19.go (2 matches)
5353
--------------------------------------------------------------------------------
54-
  47 | func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials, error) {
54+
  47 | func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials, error) {
5555
 ------------------------------------------------------------------------------
56-
  55 | func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) {
56+
  55 | func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) {

0 commit comments

Comments
 (0)