go-sdk/gitea/org_test.go
6543 b81847d03d
All checks were successful
continuous-integration/drone/push Build is passing
Add Repo Team Management Functions (#537)
close #526

* [x] functions
* [x] tests

Reviewed-on: #537
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-08-13 23:56:50 +08:00

50 lines
1.1 KiB
Go

// Copyright 2021 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 (
"testing"
"github.com/stretchr/testify/assert"
)
func createTestOrgRepo(t *testing.T, c *Client, name string) (func(), *Repository, error) {
_, _, err := c.GetOrg(name)
if err == nil {
_, _ = c.DeleteOrg(name)
}
_, _, err = c.CreateOrg(CreateOrgOption{
Name: name,
Visibility: VisibleTypePublic,
RepoAdminChangeTeamAccess: true,
})
if !assert.NoError(t, err) {
return nil, nil, err
}
_, _, err = c.GetRepo(name, name)
if err == nil {
_, _ = c.DeleteRepo(name, name)
}
repo, _, err := c.CreateOrgRepo(name, CreateRepoOption{
Name: name,
Description: "A test Repo: " + name,
AutoInit: true,
Gitignores: "C,C++",
License: "MIT",
Readme: "Default",
IssueLabels: "Default",
Private: false,
})
assert.NoError(t, err)
assert.NotNil(t, repo)
return func() {
_, _ = c.DeleteRepo(name, name)
_, _ = c.DeleteOrg(name)
}, repo, err
}