gitee.com/openeuler/go-gitee@v0.0.0-20220530104019-3af895bc380c/test/api_test.go (about) 1 package test 2 3 import ( 4 "gitee.com/openeuler/go-gitee/gitee" 5 "golang.org/x/net/context" 6 "golang.org/x/oauth2" 7 "testing" 8 ) 9 10 const ( 11 testOrg = "cve-manage-test" 12 testRepo = "config" 13 ) 14 15 var client *gitee.APIClient 16 17 func init() { 18 token := "your gitee token" 19 20 ts := oauth2.StaticTokenSource( 21 &oauth2.Token{AccessToken: token}, 22 ) 23 24 conf := gitee.NewConfiguration() 25 conf.HTTPClient = oauth2.NewClient(context.Background(), ts) 26 27 client = gitee.NewAPIClient(conf) 28 } 29 30 func TestPutV5ReposOwnerRepoPullsNumberLabels(t *testing.T) { 31 op := gitee.PullRequestLabelPostParam{ 32 Body: []string{"feature", "go-gitee-test"}, 33 } 34 labels, _, err := client.PullRequestsApi.PutV5ReposOwnerRepoPullsNumberLabels(context.Background(), testOrg, testRepo, 1, op) 35 if err != nil { 36 t.Error(err) 37 } else { 38 t.Log(labels) 39 } 40 } 41 42 func TestPutV5ReposOwnerRepoIssuesNumberLabels(t *testing.T) { 43 op := gitee.PullRequestLabelPostParam{ 44 Body: []string{"feature", "go-gitee-test"}, 45 } 46 labels, _, err := client.LabelsApi.PutV5ReposOwnerRepoIssuesNumberLabels(context.Background(), testOrg, testRepo, "I3A2AO", op) 47 if err != nil { 48 t.Error(err) 49 } else { 50 t.Log(labels) 51 } 52 53 } 54 55 func TestPatchV5ReposOwnerIssuesNumber(t *testing.T) { 56 body := gitee.IssueUpdateParam{ 57 Repo: testRepo, 58 Collaborators: "zhangjianjun_code", 59 } 60 _, _, err := client.IssuesApi.PatchV5ReposOwnerIssuesNumber(context.Background(), testOrg, "I3IZ20", body) 61 if err != nil { 62 t.Error(err) 63 } 64 }