Skip to content

Commit

Permalink
Merge branch 'token-resource-tests' into 'main'
Browse files Browse the repository at this point in the history
Add tests for `gitlabci_runner_token` resource

See merge request rsrchboy/terraform-provider-gitlabci!16
  • Loading branch information
rsrchboy committed Feb 3, 2022
2 parents 081564d + 3a7c52e commit 01734a3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions internal/provider/resource_gitlabci_runner_token_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package provider

import (
"fmt"
"os"
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccResourceRunnerToken(t *testing.T) {

token := os.Getenv("RUNNER_REGISTRATION_TOKEN")
if token == "" {
t.Skip("$RUNNER_REGISTRATION_TOKEN not set; skipping registration tests")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccResourceRunnerToken, token),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("gitlabci_runner_token.foo", "token"),
resource.TestCheckResourceAttrSet("gitlabci_runner_token.foo", "runner_id"),
resource.TestMatchResourceAttr("gitlabci_runner_token.foo", "runner_id", regexp.MustCompile(`^\d+$`)),
),
},
},
})
}

const testAccResourceRunnerToken = `
resource "gitlabci_runner_token" "foo" {
registration_token = "%s"
}
`

0 comments on commit 01734a3

Please sign in to comment.