a56a62a4df
- Bump amount of cron tasks that the dev image of Gitea has to 21. - Fix TestAdminCronTasks. Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/578 Reviewed-by: techknowlogick <techknowlogick@gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-committed-by: Gusted <williamzijl7@hotmail.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package gitea
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAdminOrg(t *testing.T) {
|
|
log.Println("== TestAdminOrg ==")
|
|
c := newTestClient()
|
|
user, _, err := c.GetMyUserInfo()
|
|
assert.NoError(t, err)
|
|
|
|
orgName := "NewTestOrg"
|
|
newOrg, _, err := c.AdminCreateOrg(user.UserName, CreateOrgOption{
|
|
Name: orgName,
|
|
FullName: orgName + " FullName",
|
|
Description: "test adminCreateOrg",
|
|
Visibility: VisibleTypePublic,
|
|
})
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, newOrg)
|
|
assert.EqualValues(t, orgName, newOrg.UserName)
|
|
|
|
orgs, _, err := c.AdminListOrgs(AdminListOrgsOptions{})
|
|
assert.NoError(t, err)
|
|
if assert.True(t, len(orgs) >= 1) {
|
|
orgs = orgs[len(orgs)-1:]
|
|
assert.EqualValues(t, newOrg.ID, orgs[0].ID)
|
|
}
|
|
|
|
_, err = c.DeleteOrg(orgName)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestAdminCronTasks(t *testing.T) {
|
|
log.Println("== TestAdminCronTasks ==")
|
|
c := newTestClient()
|
|
|
|
tasks, _, err := c.ListCronTasks(ListCronTaskOptions{})
|
|
assert.NoError(t, err)
|
|
assert.Len(t, tasks, 21)
|
|
_, err = c.RunCronTasks(tasks[0].Name)
|
|
assert.NoError(t, err)
|
|
}
|