forked from forgejo/forgejo
Refactor AssertExistsAndLoadBean to use generics (#20797)
* Refactor AssertExistsAndLoadBean to use generics * Fix tests Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
e3308a092a
commit
86c85c19b6
159 changed files with 888 additions and 888 deletions
|
@ -27,7 +27,7 @@ func TestOAuth2Application(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAPICreateOAuth2Application(t *testing.T) {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
appBody := api.CreateOAuth2ApplicationOptions{
|
||||
Name: "test-app-1",
|
||||
RedirectURIs: []string{
|
||||
|
@ -51,7 +51,7 @@ func testAPICreateOAuth2Application(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAPIListOAuth2Applications(t *testing.T) {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
session := loginUser(t, user.Name)
|
||||
token := getTokenForLoggedInUser(t, session)
|
||||
|
||||
|
@ -61,7 +61,7 @@ func testAPIListOAuth2Applications(t *testing.T) {
|
|||
RedirectURIs: []string{
|
||||
"http://www.google.com",
|
||||
},
|
||||
}).(*auth.OAuth2Application)
|
||||
})
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2?token=%s", token)
|
||||
req := NewRequest(t, "GET", urlStr)
|
||||
|
@ -80,14 +80,14 @@ func testAPIListOAuth2Applications(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAPIDeleteOAuth2Application(t *testing.T) {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
session := loginUser(t, user.Name)
|
||||
token := getTokenForLoggedInUser(t, session)
|
||||
|
||||
oldApp := unittest.AssertExistsAndLoadBean(t, &auth.OAuth2Application{
|
||||
UID: user.ID,
|
||||
Name: "test-app-1",
|
||||
}).(*auth.OAuth2Application)
|
||||
})
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", oldApp.ID, token)
|
||||
req := NewRequest(t, "DELETE", urlStr)
|
||||
|
@ -101,7 +101,7 @@ func testAPIDeleteOAuth2Application(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAPIGetOAuth2Application(t *testing.T) {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
session := loginUser(t, user.Name)
|
||||
token := getTokenForLoggedInUser(t, session)
|
||||
|
||||
|
@ -111,7 +111,7 @@ func testAPIGetOAuth2Application(t *testing.T) {
|
|||
RedirectURIs: []string{
|
||||
"http://www.google.com",
|
||||
},
|
||||
}).(*auth.OAuth2Application)
|
||||
})
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", existApp.ID, token)
|
||||
req := NewRequest(t, "GET", urlStr)
|
||||
|
@ -131,7 +131,7 @@ func testAPIGetOAuth2Application(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAPIUpdateOAuth2Application(t *testing.T) {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
|
||||
existApp := unittest.AssertExistsAndLoadBean(t, &auth.OAuth2Application{
|
||||
UID: user.ID,
|
||||
|
@ -139,7 +139,7 @@ func testAPIUpdateOAuth2Application(t *testing.T) {
|
|||
RedirectURIs: []string{
|
||||
"http://www.google.com",
|
||||
},
|
||||
}).(*auth.OAuth2Application)
|
||||
})
|
||||
|
||||
appBody := api.CreateOAuth2ApplicationOptions{
|
||||
Name: "test-app-1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue