forked from databricks/terraform-provider-databricks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
databricks#3468: added acceptance tests for data_users
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccDataSourceDataUsers_DisplayNameContains(t *testing.T) { | ||
accountLevel(t, step{ | ||
Template: ` | ||
data "databricks_data_users" "this" { | ||
display_name_contains = "testuser" | ||
}`, | ||
Check: func(s *terraform.State) error { | ||
r, ok := s.RootModule().Resources["data.databricks_data_users.this"] | ||
if !ok { | ||
return fmt.Errorf("data not found in state") | ||
} | ||
ids := r.Primary.Attributes["users.#"] | ||
if ids == "" { | ||
return fmt.Errorf("users is empty: %v", r.Primary.Attributes) | ||
} | ||
return nil | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccDataSourceDataUsers_UserNameContains(t *testing.T) { | ||
accountLevel(t, step{ | ||
Template: ` | ||
data "databricks_data_users" "this" { | ||
user_name_contains = "example.com" | ||
}`, | ||
Check: func(s *terraform.State) error { | ||
r, ok := s.RootModule().Resources["data.databricks_data_users.this"] | ||
if !ok { | ||
return fmt.Errorf("data not found in state") | ||
} | ||
usersCount := r.Primary.Attributes["users.#"] | ||
if usersCount == "" || usersCount == "0" { | ||
return fmt.Errorf("users list is empty: %v", r.Primary.Attributes) | ||
} | ||
return nil | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccDataSourceDataUsers_NoFilters(t *testing.T) { | ||
accountLevel(t, step{ | ||
Template: ` | ||
data "databricks_data_users" "this" { | ||
}`, | ||
Check: func(s *terraform.State) error { | ||
r, ok := s.RootModule().Resources["data.databricks_data_users.this"] | ||
if !ok { | ||
return fmt.Errorf("data not found in state") | ||
} | ||
usersCount := r.Primary.Attributes["users.#"] | ||
if usersCount == "" || usersCount == "0" { | ||
return fmt.Errorf("users list is empty: %v", r.Primary.Attributes) | ||
} | ||
return nil | ||
}, | ||
}) | ||
} |