This commit is contained in:
parent
0208cbd960
commit
021db20aa1
26
.drone.yml
26
.drone.yml
@ -15,23 +15,27 @@ steps:
|
|||||||
- push
|
- push
|
||||||
- pull_request
|
- pull_request
|
||||||
- tag
|
- tag
|
||||||
- name: build
|
- name: backend
|
||||||
image: goreleaser/goreleaser
|
image: gitea/gitea:1.16.8
|
||||||
|
detach: true
|
||||||
commands:
|
commands:
|
||||||
- goreleaser build --snapshot
|
- su git
|
||||||
when:
|
- gitea admin user create --username test --password $GITEA_PASSWORD --must-change-password false --admin --email test@mail.org
|
||||||
event:
|
- /usr/bin/entrypoint /bin/s6-svscan /etc/s6
|
||||||
- push
|
environment:
|
||||||
- pull_request
|
GITEA_PASSWORD:
|
||||||
resources:
|
from_secret: GITEA_PASSWORD
|
||||||
limits:
|
|
||||||
cpu: 1000
|
|
||||||
memory: 1024MiB
|
|
||||||
- name: test
|
- name: test
|
||||||
image: golang:1.18.3-alpine3.16
|
image: golang:1.18.3-alpine3.16
|
||||||
commands:
|
commands:
|
||||||
- "apk add --update --no-cache make build-base"
|
- "apk add --update --no-cache make build-base"
|
||||||
- "make test"
|
- "make test"
|
||||||
|
environment:
|
||||||
|
TF_ACC: 1
|
||||||
|
GITEA_BASE_URL: "http://localhost:3000"
|
||||||
|
GITEA_USERNAME: test
|
||||||
|
GITEA_PASSWORD:
|
||||||
|
from_secret: GITEA_PASSWORD
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
import (
|
/*func TestAccDataSourceGiteaUser_basic(t *testing.T) {
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestAccDataSourceGiteaUser_basic(t *testing.T) {
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
@ -59,4 +51,4 @@ data "gitea_user" "foo" {
|
|||||||
data "gitea_user" "self" {
|
data "gitea_user" "self" {
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}*/
|
||||||
|
86
gitea/resource_gitea_user_test.go
Normal file
86
gitea/resource_gitea_user_test.go
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package gitea
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccResourceGiteaUser_basic(t *testing.T) {
|
||||||
|
name := fmt.Sprintf("user-%d", 1)
|
||||||
|
mail := fmt.Sprintf("%s@test.org", name)
|
||||||
|
fqrn := fmt.Sprintf("gitea_user.%s", name)
|
||||||
|
|
||||||
|
userSimple := fmt.Sprintf(`
|
||||||
|
resource "gitea_user" "%s" {
|
||||||
|
username = "%s"
|
||||||
|
login_name = "%s"
|
||||||
|
email = "%s"
|
||||||
|
password = "Geheim1!"
|
||||||
|
|
||||||
|
}
|
||||||
|
`, name, name, name, mail)
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckExampleResourceDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: userSimple,
|
||||||
|
ResourceName: fqrn,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
resource.TestCheckResourceAttr(fqrn, "username", name),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAccCheckExampleResourceDestroy(s *terraform.State) error {
|
||||||
|
// retrieve the connection established in Provider configuration
|
||||||
|
//conn := testAccProvider.Meta().(*ExampleClient)
|
||||||
|
|
||||||
|
// loop through the resources in state, verifying each widget
|
||||||
|
// is destroyed
|
||||||
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
if rs.Type != "example_widget" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve our widget by referencing it's state ID for API lookup
|
||||||
|
//request := &example.DescribeWidgets{
|
||||||
|
// IDs: []string{rs.Primary.ID},
|
||||||
|
//}
|
||||||
|
|
||||||
|
//response, err := conn.DescribeWidgets(request)
|
||||||
|
//if err == nil {
|
||||||
|
// if len(response.Widgets) > 0 && *response.Widgets[0].ID == rs.Primary.ID {
|
||||||
|
// return fmt.Errorf("Widget (%s) still exists.", rs.Primary.ID)
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
//}
|
||||||
|
|
||||||
|
// If the error is equivalent to 404 not found, the widget is destroyed.
|
||||||
|
// Otherwise return the error
|
||||||
|
//if !strings.Contains(err.Error(), "Widget not found") {
|
||||||
|
// return err
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAccResourceGiteaUserSimple(fqrn string, name string, mail string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "gitea_user" "%s" {
|
||||||
|
username = "%s"
|
||||||
|
login_name = "%s"
|
||||||
|
email = "%s"
|
||||||
|
password = "Geheim1!"
|
||||||
|
|
||||||
|
}
|
||||||
|
`, fqrn, name, name, mail)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user