Skip to content

Commit

Permalink
Fix acceptance tests (#16)
Browse files Browse the repository at this point in the history
* Fix acceptance tests

* Add testacc target
  • Loading branch information
hkobayash authored Oct 3, 2021
1 parent 66849a2 commit 2586142
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ install: $(BINARY)
test:
go test -v ./...

testacc:
TF_ACC=1 go test -v ./...

docker_test:
$(TEST_ENV) go test -v ./...
15 changes: 9 additions & 6 deletions internal/provider/resource_ldap_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccLDAPObject_Basic(t *testing.T) {
Config: testAccCheckLDAPObjectConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckLDAPObjectExists("ldap_object.jdoe"),
resource.TestCheckResourceAttr("ldap_object.jdoe", "dn", "uid=jdoe,dv=example,dc=com"),
resource.TestCheckResourceAttr("ldap_object.jdoe", "dn", "uid=jdoe,dc=example,dc=com"),
//resource.TestCheckResourceAttr("ldap_object.jdoe", "base_dn", "dc=example,dc=com"),
resource.TestCheckResourceAttr("ldap_object.jdoe", "object_classes.0", "inetOrgPerson"),
resource.TestCheckResourceAttr("ldap_object.jdoe", "object_classes.1", "posixAccount"),
Expand All @@ -36,14 +36,17 @@ func testAccCheckLDAPObjectDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*ldap.Conn)
for _, r := range s.RootModule().Resources {
dn := r.Primary.Attributes["dn"]
sr, err := helperSearchRequest(dn, conn)
_, err := helperSearchRequest(dn, conn)
if err != nil {
if err, ok := err.(*ldap.Error); ok {
if err.ResultCode == 32 { // no such object
continue
}
}
return err
}
if len(sr.Entries) != 0 {
err = errors.New("Number of records greater than 0 for " + dn)
return err
}

return errors.New("Number of records greater than 0 for " + dn)
}
return nil
}
Expand Down

0 comments on commit 2586142

Please sign in to comment.