-
Notifications
You must be signed in to change notification settings - Fork 968
Expand file tree
/
Copy pathdata_source_github_actions_remove_token_test.go
More file actions
58 lines (48 loc) · 1.57 KB
/
data_source_github_actions_remove_token_test.go
File metadata and controls
58 lines (48 loc) · 1.57 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-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccGithubActionsRemoveTokenDataSource(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
t.Run("get a repository remove token without error", func(t *testing.T) {
config := fmt.Sprintf(`
resource "github_repository" "test" {
name = "tf-acc-test-%[1]s"
auto_init = true
vulnerability_alerts = true
}
data "github_actions_remove_token" "test" {
repository = github_repository.test.id
}
`, randomID)
check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.github_actions_remove_token.test", "repository", fmt.Sprintf("tf-acc-test-%s", randomID)),
resource.TestCheckResourceAttrSet("data.github_actions_remove_token.test", "token"),
resource.TestCheckResourceAttrSet("data.github_actions_remove_token.test", "expires_at"),
)
testCase := func(t *testing.T, mode string) {
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, mode) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: check,
},
},
})
}
t.Run("with an anonymous account", func(t *testing.T) {
t.Skip("anonymous account not supported for this operation")
})
t.Run("with an individual account", func(t *testing.T) {
testCase(t, individual)
})
t.Run("with an organization account", func(t *testing.T) {
testCase(t, organization)
})
})
}