-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from NJUPT-SAST/feat/lark
fix: Fix the issue where the oauth client module could't store JSONB in
- Loading branch information
Showing
8 changed files
with
87 additions
and
81 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
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
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
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 |
---|---|---|
@@ -1,27 +1,26 @@ | ||
package model | ||
|
||
import ( | ||
"database/sql" | ||
"log" | ||
"encoding/json" | ||
"fmt" | ||
"testing" | ||
|
||
"gorm.io/datatypes" | ||
) | ||
|
||
func TestInsertOAuth2Info(t *testing.T) { | ||
db, err := sql.Open("postgres", "your-database-connection-string") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer db.Close() | ||
|
||
info := `{"login":"user","id":123,"node_id":"node_id","avatar_url":"url","gravatar_id":"","url":"url","html_url":"url","followers_url":"url","following_url":"url","gists_url":"url","starred_url":"url","subscriptions_url":"https://api.github.com/users/user/subscriptions","organizations_url":"https://api.github.com/users/user/orgs","repos_url":"https://api.github.com/users/user/repos","events_url":"https://api.github.com/users/user/events{/privacy}","received_events_url":"https://api.github.com/users/user/received_events","type":"User","site_admin":false,"name":"max","company":"@Xiaomi @sast @GreenPomelo","blog":"blog_url","location":"Nanjing","email":null,"hireable":null,"bio":"From Nanjing University of Posts and Telecommunications, member of @SAST. Working on 👀 visualization & 🌐 web dev\\r\\n","twitter_username":null,"public_repos":48,"public_gists":3,"followers":65,"following":148,"created_at":"2020-02-07T09:21:13Z","updated_at":"2024-07-19T12:26:27Z"}` | ||
info := `{"login":"user","id":123,"node_id":"node_id","avatar_url":"url","gravatar_id":"","url":"url","html_url":"url","followers_url":"url","following_url":"url","gists_url":"url","starred_url":"url","subscriptions_url":"https://api.github.com/users/user/subscriptions","organizations_url":"https://api.github.com/users/user/orgs","repos_url":"https://api.github.com/users/user/repos","events_url":"https://api.github.com/users/user/events{/privacy}","received_events_url":"https://api.github.com/users/user/received_events","type":"User","site_admin":false,"name":"max","company":"@sast","blog":"blog_url","location":"Nanjing","email":null,"hireable":null,"bio":"From Nanjing University of Posts and Telecommunications, member of @SAST. Working on 👀 visualization & 🌐 web dev\\r\\n","twitter_username":null,"public_repos":48,"public_gists":3,"followers":65,"following":148,"created_at":"2020-02-07T09:21:13Z","updated_at":"2024-07-19T12:26:27Z"}` | ||
testData := OAuth2Info{ | ||
Client: "github", | ||
Info: datatypes.JSON(info), | ||
OauthID: "60775796", | ||
UserID: "b21041313", | ||
Info: json.RawMessage(info), | ||
OauthID: "oauthid", | ||
UserID: "userid", | ||
} | ||
|
||
UpsetOauthInfo(testData) | ||
res, err := OauthInfoByUID("github", "oauthid") | ||
if err != nil { | ||
t.Errorf("InsertOAuth2Info failed: %s", err) | ||
} | ||
|
||
fmt.Println("jsonStr: ", string(res.Info)) | ||
t.Log("InsertOAuth2Info test passed") | ||
} |
Oops, something went wrong.