0
0
mirror of https://github.com/thegeeklab/wp-gitea-release.git synced 2024-11-22 00:00:41 +00:00

cleanup gitea options struct

This commit is contained in:
Robert Kaussow 2024-05-12 00:03:07 +02:00
parent 14e918c6cb
commit d88993d496
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
3 changed files with 17 additions and 17 deletions

View File

@ -29,10 +29,10 @@ type Client struct {
type Release struct { type Release struct {
client APIClient client APIClient
Opt ReleaseOpt Opt ReleaseOptions
} }
type ReleaseOpt struct { type ReleaseOptions struct {
Owner string Owner string
Repo string Repo string
Tag string Tag string
@ -56,7 +56,7 @@ func NewClient(url, key string, client *http.Client) (*Client, error) {
client: c, client: c,
Release: &Release{ Release: &Release{
client: c, client: c,
Opt: ReleaseOpt{}, Opt: ReleaseOptions{},
}, },
}, nil }, nil
} }

View File

@ -18,13 +18,13 @@ import (
func TestReleaseFind(t *testing.T) { func TestReleaseFind(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
opt ReleaseOpt opt ReleaseOptions
want *gitea.Release want *gitea.Release
wantErr error wantErr error
}{ }{
{ {
name: "find release by tag", name: "find release by tag",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v1.0.0", Tag: "v1.0.0",
@ -35,7 +35,7 @@ func TestReleaseFind(t *testing.T) {
}, },
{ {
name: "release not found", name: "release not found",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v1.1.0", Tag: "v1.1.0",
@ -84,13 +84,13 @@ func TestReleaseFind(t *testing.T) {
func TestReleaseCreate(t *testing.T) { func TestReleaseCreate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
opt ReleaseOpt opt ReleaseOptions
want *gitea.Release want *gitea.Release
wantErr error wantErr error
}{ }{
{ {
name: "create release", name: "create release",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v1.1.0", Tag: "v1.1.0",
@ -109,7 +109,7 @@ func TestReleaseCreate(t *testing.T) {
}, },
{ {
name: "create draft release", name: "create draft release",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v1.2.0", Tag: "v1.2.0",
@ -128,7 +128,7 @@ func TestReleaseCreate(t *testing.T) {
}, },
{ {
name: "create prerelease", name: "create prerelease",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v1.3.0-rc1", Tag: "v1.3.0-rc1",
@ -192,7 +192,7 @@ func TestReleaseAddAttachments(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
opt ReleaseOpt opt ReleaseOptions
files []string files []string
fileExists string fileExists string
wantErr error wantErr error
@ -200,7 +200,7 @@ func TestReleaseAddAttachments(t *testing.T) {
}{ }{
{ {
name: "add new attachments", name: "add new attachments",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v2.0.0", Tag: "v2.0.0",
@ -212,7 +212,7 @@ func TestReleaseAddAttachments(t *testing.T) {
}, },
{ {
name: "fail on existing attachments", name: "fail on existing attachments",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v2.0.0", Tag: "v2.0.0",
@ -224,7 +224,7 @@ func TestReleaseAddAttachments(t *testing.T) {
}, },
{ {
name: "overwrite on existing attachments", name: "overwrite on existing attachments",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v2.0.0", Tag: "v2.0.0",
@ -236,7 +236,7 @@ func TestReleaseAddAttachments(t *testing.T) {
}, },
{ {
name: "skip on existing attachments", name: "skip on existing attachments",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v2.0.0", Tag: "v2.0.0",
@ -248,7 +248,7 @@ func TestReleaseAddAttachments(t *testing.T) {
}, },
{ {
name: "fail on invalid file", name: "fail on invalid file",
opt: ReleaseOpt{ opt: ReleaseOptions{
Owner: "test-owner", Owner: "test-owner",
Repo: "test-repo", Repo: "test-repo",
Tag: "v2.0.0", Tag: "v2.0.0",

View File

@ -74,7 +74,7 @@ func (p *Plugin) Execute() error {
return fmt.Errorf("failed to create Gitea client: %w", err) return fmt.Errorf("failed to create Gitea client: %w", err)
} }
client.Release.Opt = gitea.ReleaseOpt{ client.Release.Opt = gitea.ReleaseOptions{
Owner: p.Metadata.Repository.Owner, Owner: p.Metadata.Repository.Owner,
Repo: p.Metadata.Repository.Name, Repo: p.Metadata.Repository.Name,
Tag: strings.TrimPrefix(p.Settings.CommitRef, "refs/tags/"), Tag: strings.TrimPrefix(p.Settings.CommitRef, "refs/tags/"),