forked from integrations/terraform-provider-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_source_github_dependabot_secrets_test.go
More file actions
58 lines (50 loc) · 1.69 KB
/
data_source_github_dependabot_secrets_test.go
File metadata and controls
58 lines (50 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package github
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccGithubDependabotSecretsDataSource(t *testing.T) {
t.Run("queries dependabot secrets from a repository", func(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
repoName := fmt.Sprintf("%srepo-dep-secrets-%s", testResourcePrefix, randomID)
config := fmt.Sprintf(`
resource "github_repository" "test" {
name = "%s"
auto_init = true
}
resource "github_dependabot_secret" "test" {
secret_name = "dep_secret_1"
repository = github_repository.test.name
value = "foo"
}
`, repoName)
config2 := config + `
data "github_dependabot_secrets" "test" {
name = github_repository.test.name
}
`
check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.github_dependabot_secrets.test", "name", repoName),
resource.TestCheckResourceAttr("data.github_dependabot_secrets.test", "secrets.#", "1"),
resource.TestCheckResourceAttr("data.github_dependabot_secrets.test", "secrets.0.name", "DEP_SECRET_1"),
resource.TestCheckResourceAttrSet("data.github_dependabot_secrets.test", "secrets.0.created_at"),
resource.TestCheckResourceAttrSet("data.github_dependabot_secrets.test", "secrets.0.updated_at"),
)
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessHasOrgs(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(),
},
{
Config: config2,
Check: check,
},
},
})
})
}