refactor: tests - rename some functions

This commit is contained in:
Dawid Wysokiński 2023-09-03 06:26:58 +02:00
parent 56b1ca02b8
commit 4659663f09
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
4 changed files with 11 additions and 8 deletions

View File

@ -29,7 +29,7 @@ func TestRepositorySecretResource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckRepositorySecretResourceDestroy(repo.ID, name, newName),
CheckDestroy: checkRepositorySecretResourceDestroy(repo.ID, name, newName),
Steps: []resource.TestStep{
{ // create secret
Config: fmt.Sprintf(`
@ -149,7 +149,7 @@ resource "woodpecker_repository_secret" "test_secret" {
})
}
func testAccCheckRepositorySecretResourceDestroy(repoID int64, names ...string) func(state *terraform.State) error {
func checkRepositorySecretResourceDestroy(repoID int64, names ...string) func(state *terraform.State) error {
return func(state *terraform.State) error {
secrets, err := woodpeckerClient.SecretList(repoID)
if err != nil {

View File

@ -27,7 +27,7 @@ func TestRepositoryResource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckRepositoryResourceDestroy(repo1.FullName, repo2.FullName),
CheckDestroy: checkRepositoryResourceDestroy(repo1.FullName, repo2.FullName),
Steps: []resource.TestStep{
{ // create repo
Config: fmt.Sprintf(`
@ -197,7 +197,7 @@ resource "woodpecker_repository" "test_repo" {
})
}
func testAccCheckRepositoryResourceDestroy(names ...string) func(state *terraform.State) error {
func checkRepositoryResourceDestroy(names ...string) func(state *terraform.State) error {
return func(state *terraform.State) error {
repos, err := woodpeckerClient.RepoListOpts(true, true)
if err != nil {
@ -230,6 +230,9 @@ func createRepo(tb testing.TB) *gitea.Repository {
if err != nil {
tb.Fatalf("got unexpected error while creating repo: %s", err)
}
tb.Cleanup(func() {
_, _ = giteaClient.DeleteRepo(repo.Owner.UserName, repo.Name)
})
return repo
}

View File

@ -26,7 +26,7 @@ func TestSecretResource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckSecretResourceDestroy(name, newName),
CheckDestroy: checkSecretResourceDestroy(name, newName),
Steps: []resource.TestStep{
{ // create secret
Config: fmt.Sprintf(`
@ -137,7 +137,7 @@ resource "woodpecker_secret" "test_secret" {
})
}
func testAccCheckSecretResourceDestroy(names ...string) func(state *terraform.State) error {
func checkSecretResourceDestroy(names ...string) func(state *terraform.State) error {
return func(state *terraform.State) error {
secrets, err := woodpeckerClient.GlobalSecretList()
if err != nil {

View File

@ -22,7 +22,7 @@ func TestUserResource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckUserResourceDestroy(login, newLogin),
CheckDestroy: checkUserResourceDestroy(login, newLogin),
Steps: []resource.TestStep{
{ // create user
Config: fmt.Sprintf(`
@ -103,7 +103,7 @@ resource "woodpecker_user" "test_user" {
})
}
func testAccCheckUserResourceDestroy(logins ...string) func(state *terraform.State) error {
func checkUserResourceDestroy(logins ...string) func(state *terraform.State) error {
return func(state *terraform.State) error {
users, err := woodpeckerClient.UserList()
if err != nil {