@@ -8,48 +8,64 @@ import (
88 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
99)
1010
11- func TestAppCollaborator_basic (t * testing.T ) {
11+ func Test_DataSourceAppCollaborator_basic (t * testing.T ) {
1212 resource .ParallelTest (t , resource.TestCase {
13- PreCheck : func () { testDGPreCheck (t ) },
13+ PreCheck : func () { Test_DGPreCheck (t ) },
1414 Providers : testDGProviders ,
1515 Steps : []resource.TestStep {
1616 {
17- Config : testAppCollaboratorConfig ,
17+ Config : testDataSourceAppCollaboratorConfig ,
1818 Check : resource .ComposeTestCheckFunc (
19- testAppCollaborator ("data.deploygate_app_collaborator.current" ),
19+ testDataSourceAppCollaborator ("data.deploygate_app_collaborator.current" ),
2020 ),
2121 },
2222 },
2323 })
2424}
2525
26- func testAppCollaborator (n string ) resource.TestCheckFunc {
26+ func testDataSourceAppCollaborator (n string ) resource.TestCheckFunc {
2727 return func (s * terraform.State ) error {
2828 rs , ok := s .RootModule ().Resources [n ]
2929 if ! ok {
3030 return fmt .Errorf ("Can't find app users resource: %s" , n )
3131 }
3232
3333 if rs .Primary .ID == "" {
34- return fmt .Errorf ("Account Id resource ID not set" )
34+ return fmt .Errorf ("Resource ID not set" )
3535 }
3636
37- if rs .Primary .Attributes ["users " ] == "" {
38- return fmt .Errorf ("Users expected to not be nil" )
37+ if rs .Primary .Attributes ["owner " ] == "" {
38+ return fmt .Errorf ("owner expected to not be nil" )
3939 }
4040
41- if rs .Primary .Attributes ["teams " ] == "" {
42- return fmt .Errorf ("Teams expected to not be nil" )
41+ if rs .Primary .Attributes ["platform " ] == "" {
42+ return fmt .Errorf ("platform expected to not be nil" )
4343 }
4444
45- if rs .Primary .Attributes ["usage " ] == "" {
46- return fmt .Errorf ("Usage expected to not be nil" )
45+ if rs .Primary .Attributes ["app_id " ] == "" {
46+ return fmt .Errorf ("app_id expected to not be nil" )
4747 }
4848
4949 return nil
5050 }
5151}
5252
53- const testAppCollaboratorConfig = `
54- data "deploygate_app_collaborator" "current" {}
53+ const testDataSourceAppCollaboratorConfig = `
54+ data "deploygate_app_collaborator" "current" {
55+ owner = var.owner
56+ platform = var.platform
57+ app_id = var.app_id
58+ }
59+
60+ variable "platform" {
61+ type = string
62+ }
63+
64+ variable "app_id" {
65+ type = string
66+ }
67+
68+ variable "owner" {
69+ type = string
70+ }
5571`
0 commit comments