forgejo-sdk/forgejo/repo_action_test.go

41 lines
1.2 KiB
Go
Raw Normal View History

2024-09-12 20:13:17 +01:00
package forgejo
import (
"github.com/stretchr/testify/assert"
"log"
"net/http"
"testing"
)
func TestCreateRepoActionSecret(t *testing.T) {
log.Println("== TestCreateRepoActionSecret ==")
c := newTestClient()
user := createTestUser(t, "action_user", c)
c.SetSudo(user.UserName)
repo, _, err := c.CreateRepo(CreateRepoOption{Name: "Action"})
assert.NoError(t, err)
assert.NotNil(t, repo)
// create repo secret
resp, err := c.CreateRepoActionSecret(user.UserName, repo.Name, CreateSecretOption{Name: "test", Data: "test"})
assert.NoError(t, err)
assert.Equal(t, http.StatusCreated, resp.StatusCode)
// update repo secret
resp, err = c.CreateRepoActionSecret(user.UserName, repo.Name, CreateSecretOption{Name: "test", Data: "test2"})
assert.NoError(t, err)
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
// list repo secrets
secrets, _, err := c.ListRepoActionSecret(user.UserName, repo.Name, ListRepoActionSecretOption{})
assert.NoError(t, err)
assert.Len(t, secrets, 1)
2024-09-12 20:47:57 +01:00
// delete repo secret
resp, err = c.DeleteRepoActionSecret(user.UserName, repo.Name, "test")
assert.NoError(t, err)
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
2024-09-12 20:13:17 +01:00
}