-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DeleteTag & Correct DeleteReleaseByTag (#488)
* Add DeleteTag + Tests * Correct DeleteReleaseByTag func + Tests this is because of go-gitea/gitea#14563 witch fixed unreleased inconsistency Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/488 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io> Co-authored-by: 6543 <6543@obermui.de> Co-committed-by: 6543 <6543@obermui.de>
- Loading branch information
Showing
4 changed files
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// 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 TestTags(t *testing.T) { | ||
log.Println("== TestTags ==") | ||
c := newTestClient() | ||
|
||
repo, _ := createTestRepo(t, "TestTags", c) | ||
|
||
// Create Tags | ||
createTestTag(t, c, repo, "tag1") | ||
|
||
tags, _, err := c.ListRepoTags(repo.Owner.UserName, repo.Name, ListRepoTagsOptions{}) | ||
assert.NoError(t, err) | ||
assert.Len(t, tags, 1) | ||
|
||
// DeleteReleaseTag | ||
resp, err := c.DeleteTag(repo.Owner.UserName, repo.Name, "tag1") | ||
assert.NoError(t, err) | ||
assert.EqualValues(t, 204, resp.StatusCode) | ||
tags, _, err = c.ListRepoTags(repo.Owner.UserName, repo.Name, ListRepoTagsOptions{}) | ||
assert.NoError(t, err) | ||
assert.Len(t, tags, 0) | ||
} | ||
|
||
// createTestTag use create release api since there exist no api to create tag only | ||
// https://github.com/go-gitea/gitea/issues/14669 | ||
func createTestTag(t *testing.T, c *Client, repo *Repository, name string) { | ||
rel, _, err := c.CreateRelease(repo.Owner.UserName, repo.Name, CreateReleaseOption{ | ||
TagName: name, | ||
Target: "master", | ||
Title: "TMP Release", | ||
}) | ||
assert.NoError(t, err) | ||
_, err = c.DeleteRelease(repo.Owner.UserName, repo.Name, rel.ID) | ||
assert.NoError(t, err) | ||
} |