Skip to content

Commit

Permalink
form, flow unit test added
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalshit27 committed Oct 3, 2024
1 parent 7d5d1a8 commit 57ae97d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/auth0/flow/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ resource "auth0_flow" "my_flow" {
const testFlowCreate = `
resource "auth0_flow" "my_flow" {
name = "test-flow-{{.testName}}"
}
`

Expand All @@ -29,6 +30,12 @@ resource "auth0_flow" "my_flow" {
}
`

const testFlowDelete = `
resource "auth0_flow" "my_flow" {
name = "updated-test-flow-{{.testName}}"
}
`

func TestAccFlow(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand All @@ -50,6 +57,14 @@ func TestAccFlow(t *testing.T) {
resource.TestCheckResourceAttrSet("auth0_flow.my_flow", "id"),
),
},
{
Config: acctest.ParseTestName(testFlowDelete, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_flow.my_flow", "name", fmt.Sprintf("updated-test-flow-%s", t.Name())),
resource.TestCheckResourceAttrSet("auth0_flow.my_flow", "id"),
),
Destroy: true,
},
},
})
}
50 changes: 50 additions & 0 deletions internal/auth0/form/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,35 @@ resource "auth0_form" "my_form" {
}
`

const testFormUpdateEmptyNode = `
resource "auth0_form" "my_form" {
name = "updated-test-form-no-node-{{.testName}}"
ending = jsonencode({resume_flow = true})
languages { primary = "en" }
nodes = jsonencode([])
}
`

const testFormCreateWithStyle = `
resource "auth0_form" "my_form" {
name = "test-form-style-{{.testName}}"
languages { primary = "en" }
style = jsonencode({css = "h1 {\n color: white;\n text-align: center;\n}"})
}
`

const testFormCreateWithMessages = `
resource "auth0_form" "my_form" {
name = "test-form-messages-{{.testName}}"
languages { primary = "en" }
messages {
errors = jsonencode({
ERR_ACCEPTANCE_REQUIRED = "Custom error message"
})
}
}
`

func TestAccForm(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand All @@ -55,6 +84,27 @@ func TestAccForm(t *testing.T) {
resource.TestCheckResourceAttrSet("auth0_form.my_form", "id"),
),
},
{
Config: acctest.ParseTestName(testFormUpdateEmptyNode, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_form.my_form", "name", "updated-test-form-no-node-"+t.Name()),
resource.TestCheckResourceAttrSet("auth0_form.my_form", "id"),
),
},
{
Config: acctest.ParseTestName(testFormCreateWithStyle, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_form.my_form", "name", "test-form-style-"+t.Name()),
resource.TestCheckResourceAttrSet("auth0_form.my_form", "id"),
),
},
{
Config: acctest.ParseTestName(testFormCreateWithMessages, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_form.my_form", "name", "test-form-messages-"+t.Name()),
resource.TestCheckResourceAttrSet("auth0_form.my_form", "id"),
),
},
},
})
}

0 comments on commit 57ae97d

Please sign in to comment.