11package provider_test
22
33import (
4+ "fmt"
45 "testing"
56
67 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -11,42 +12,43 @@ import (
1112)
1213
1314func TestAccInvitesDataSource (t * testing.T ) {
15+ email := fmt .
Sprintf (
"tf-%[email protected] " ,
acctest .
RandInt ())
1416 rn := "data.openai_invites.test"
1517
1618 resource .Test (t , resource.TestCase {
1719 PreCheck : func () { acctest .PreCheck (t ) },
1820 ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
1921 Steps : []resource.TestStep {
2022 {
21- Config : testAccInvitesDataSourceConfig ,
23+ Config : testAccInvitesDataSourceConfig ( email ) ,
2224 ConfigStateChecks : []statecheck.StateCheck {
2325 statecheck .ExpectKnownValue (rn , tfjsonpath .New ("invites" ), knownvalue .SetPartial ([]knownvalue.Check {
2426 knownvalue .ObjectExact (map [string ]knownvalue.Check {
2527 "id" : knownvalue .NotNull (),
26- "email" : knownvalue .NotNull ( ),
28+ "email" : knownvalue .StringExact ( email ),
2729 "role" : knownvalue .StringExact ("reader" ),
28- "status" : knownvalue .StringExact ( "expired" ),
30+ "status" : knownvalue .NotNull ( ),
2931 "invited_at" : knownvalue .NotNull (),
3032 "expires_at" : knownvalue .NotNull (),
3133 "accepted_at" : knownvalue .Null (),
3234 }),
33- knownvalue .ObjectExact (map [string ]knownvalue.Check {
34- "id" : knownvalue .NotNull (),
35- "email" : knownvalue .NotNull (),
36- "role" : knownvalue .StringExact ("reader" ),
37- "status" : knownvalue .StringExact ("accepted" ),
38- "invited_at" : knownvalue .NotNull (),
39- "expires_at" : knownvalue .NotNull (),
40- "accepted_at" : knownvalue .NotNull (),
41- }),
4235 })),
4336 },
4437 },
4538 },
4639 })
4740}
4841
49- var testAccInvitesDataSourceConfig = `
42+ func testAccInvitesDataSourceConfig (email string ) string {
43+ return fmt .Sprintf (`
44+ resource "openai_invite" "test" {
45+ email = %[1]q
46+ role = "reader"
47+ }
48+
5049data "openai_invites" "test" {
50+ depends_on = [openai_invite.test]
51+ }
52+ ` , email )
53+
5154}
52- `
0 commit comments