This is an automated email from the ASF dual-hosted git repository.
zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new c82a9ad9f fix: wrong endpoint but test passed (#3958)
c82a9ad9f is described below
commit c82a9ad9f1a127dc4c9e8084954a7388e5c2225d
Author: abeizn <[email protected]>
AuthorDate: Fri Dec 16 19:47:17 2022 +0800
fix: wrong endpoint but test passed (#3958)
* fix: wrong endpoint but test passed
* fix: wrong endpoint but test passed
* fix: wrong endpoint but test passed
---
plugins/github/api/connection.go | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/plugins/github/api/connection.go b/plugins/github/api/connection.go
index 8ab726e74..126088104 100644
--- a/plugins/github/api/connection.go
+++ b/plugins/github/api/connection.go
@@ -20,11 +20,12 @@ package api
import (
"context"
"fmt"
- "github.com/apache/incubator-devlake/errors"
"net/http"
"strings"
"time"
+ "github.com/apache/incubator-devlake/errors"
+
"github.com/apache/incubator-devlake/api/shared"
"github.com/apache/incubator-devlake/plugins/core"
@@ -84,6 +85,11 @@ func TestConnection(input *core.ApiResourceInput)
(*core.ApiResourceOutput, erro
results <- VerifyResult{err:
errors.Default.Wrap(err, fmt.Sprintf("verify token failed for #%d %s", j,
token))}
return
}
+ if res.StatusCode != http.StatusOK {
+ results <- VerifyResult{err:
errors.HttpStatus(res.StatusCode).New("unexpected status code while testing
connection")}
+ return
+ }
+
githubUserOfToken := &models.GithubUserOfToken{}
err = helper.UnmarshalResponse(res, githubUserOfToken)
if err != nil {
@@ -93,10 +99,10 @@ func TestConnection(input *core.ApiResourceInput)
(*core.ApiResourceOutput, erro
results <- VerifyResult{err:
errors.BadInput.Wrap(err, fmt.Sprintf("invalid token for #%v %s", j, token))}
return
}
+
results <- VerifyResult{login: githubUserOfToken.Login}
}()
}
-
// collect verification results
logins := make([]string, 0)
allErrors := make([]error, 0)