Skip to content

Commit 6a90dec

Browse files
committed
Add custom username check
1 parent bf3c1cc commit 6a90dec

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

test/e2e/item_data_source_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,24 @@ func TestAccItemDataSource_DetectManualChanges(t *testing.T) {
334334
}
335335
bcRemoved := checks.BuildItemChecks("data.onepassword_item.test_item", removedAttrs)
336336
removedFieldsReadChecks = append(removedFieldsReadChecks, bcRemoved...)
337-
// Verify that username does not exist when fields are removed
338-
removedFieldsReadChecks = append(removedFieldsReadChecks, resource.TestCheckNoResourceAttr("data.onepassword_item.test_item", "username"))
337+
338+
// Verify that username is either not present (SDK) or empty (Connect)
339+
removedFieldsReadChecks = append(removedFieldsReadChecks, resource.TestCheckFunc(func(s *terraform.State) error {
340+
item, ok := s.RootModule().Resources["data.onepassword_item.test_item"]
341+
if !ok {
342+
return fmt.Errorf("resource not found in state")
343+
}
344+
345+
username, exists := item.Primary.Attributes["username"]
346+
if exists {
347+
// If username exists, it should be empty (Connect behavior)
348+
if username != "" {
349+
return fmt.Errorf("expected username to be empty or not present, got %q", username)
350+
}
351+
}
352+
// If username doesn't exist, that's also valid (SDK behavior)
353+
return nil
354+
}))
339355

340356
resource.Test(t, resource.TestCase{
341357
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,

0 commit comments

Comments
 (0)