Skip to content

Commit

Permalink
Fix test race condition (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Feb 19, 2024
1 parent fddf1da commit 3638632
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions githubauth/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,34 @@ func TestApp_AppToken(t *testing.T) {
if got, want := string(token), string(cachedToken); got != want {
t.Errorf("expected %q to be %q (should have been cached)", got, want)
}
}

func TestApp_OAuthAppTokenSource(t *testing.T) {
t.Parallel()

t.Run("oauth_token_source", func(t *testing.T) {
t.Parallel()
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
t.Fatal(err)
}

oauthToken, err := app.OAuthAppTokenSource().Token()
if err != nil {
t.Fatal(err)
}
app, err := NewApp("my-app-id", "my-install-id", privateKey)
if err != nil {
t.Fatal(err)
}

if got, want := oauthToken.AccessToken, string(token); got != want {
t.Errorf("expected %q to be %q", got, want)
}
})
token, err := app.AppToken()
if err != nil {
t.Fatal(err)
}

oauthToken, err := app.OAuthAppTokenSource().Token()
if err != nil {
t.Fatal(err)
}

if got, want := oauthToken.AccessToken, string(token); got != want {
t.Errorf("expected %q to be %q", got, want)
}
}

func TestApp_AccessToken(t *testing.T) {
Expand Down

0 comments on commit 3638632

Please sign in to comment.