2020-01-28 05:45:53 +00:00
|
|
|
// 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()
|
2020-09-14 03:37:09 +01:00
|
|
|
user, _, err := c.GetMyUserInfo()
|
2020-01-28 05:45:53 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
orgName := "NewTestOrg"
|
2020-09-14 03:37:09 +01:00
|
|
|
newOrg, _, err := c.AdminCreateOrg(user.UserName, CreateOrgOption{
|
2020-07-30 20:46:18 +01:00
|
|
|
Name: orgName,
|
2020-01-28 05:45:53 +00:00
|
|
|
FullName: orgName + " FullName",
|
|
|
|
Description: "test adminCreateOrg",
|
2020-07-16 03:17:33 +01:00
|
|
|
Visibility: VisibleTypePublic,
|
2020-01-28 05:45:53 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEmpty(t, newOrg)
|
|
|
|
assert.EqualValues(t, orgName, newOrg.UserName)
|
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
orgs, _, err := c.AdminListOrgs(AdminListOrgsOptions{})
|
2020-01-28 05:45:53 +00:00
|
|
|
assert.NoError(t, err)
|
2021-01-30 13:25:21 +00:00
|
|
|
if assert.True(t, len(orgs) >= 1) {
|
|
|
|
orgs = orgs[len(orgs)-1:]
|
|
|
|
assert.EqualValues(t, newOrg.ID, orgs[0].ID)
|
|
|
|
}
|
2020-01-28 05:45:53 +00:00
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
_, err = c.DeleteOrg(orgName)
|
2020-01-28 05:45:53 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2020-09-07 05:11:39 +01:00
|
|
|
|
|
|
|
func TestAdminCronTasks(t *testing.T) {
|
|
|
|
log.Println("== TestAdminCronTasks ==")
|
|
|
|
c := newTestClient()
|
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
tasks, _, err := c.ListCronTasks(ListCronTaskOptions{})
|
2020-09-07 05:11:39 +01:00
|
|
|
assert.NoError(t, err)
|
2021-05-27 23:02:01 +01:00
|
|
|
assert.Len(t, tasks, 18)
|
2020-09-14 03:37:09 +01:00
|
|
|
_, err = c.RunCronTasks(tasks[0].Name)
|
|
|
|
assert.NoError(t, err)
|
2020-09-07 05:11:39 +01:00
|
|
|
}
|