Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanndickson committed Nov 27, 2024
1 parent 2840903 commit 2fe148d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions internal/provider/user_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestAccUserDataSource(t *testing.T) {
Username: ptr.Ref(user.Username),
}
resource.Test(t, resource.TestCase{
IsUnitTest: true,
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
Expand All @@ -75,6 +76,7 @@ func TestAccUserDataSource(t *testing.T) {
ID: ptr.Ref(user.ID.String()),
}
resource.Test(t, resource.TestCase{
IsUnitTest: true,
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
// User by ID
Expand All @@ -92,6 +94,7 @@ func TestAccUserDataSource(t *testing.T) {
Token: client.SessionToken(),
}
resource.Test(t, resource.TestCase{
IsUnitTest: true,
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
// Neither ID nor Username
Expand All @@ -104,6 +107,24 @@ func TestAccUserDataSource(t *testing.T) {
})
})

t.Run("InvalidUUIDError", func(t *testing.T) {
cfg := testAccUserDataSourceConfig{
URL: client.URL.String(),
Token: client.SessionToken(),
ID: ptr.Ref("invalid-uuid"),
}
resource.Test(t, resource.TestCase{
IsUnitTest: true,
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: cfg.String(t),
ExpectError: regexp.MustCompile(`The provided value cannot be parsed as a UUID`),
},
},
})
})
}

type testAccUserDataSourceConfig struct {
Expand Down

0 comments on commit 2fe148d

Please sign in to comment.