generated from hashicorp/terraform-provider-scaffolding-framework
-
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.
- Loading branch information
Andrei-Alexandru Dobre
committed
Jan 16, 2025
1 parent
b927631
commit 73d2b7a
Showing
19 changed files
with
342 additions
and
15 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
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
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,54 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/essent/terraform-provider-slack/internal/testBed" | ||
"github.com/golang/mock/gomock" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/slack-go/slack" | ||
) | ||
|
||
func Test_WHATEVER(t *testing.T) { | ||
defer testBed.Finish() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
|
||
m := testBed.MockSlackClient() | ||
m.EXPECT().AuthTest(gomock.Any()).Return(&slack.AuthTestResponse{}, nil).AnyTimes() | ||
}, | ||
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
PreConfig: func() { | ||
// arrange | ||
u := testBed.NewUserBuilder().WithID("<ID>").WithName("<NAME>").WithEmail("<GIVEN_EMAIL>").Build() | ||
|
||
m := testBed.MockSlackClient() | ||
m.EXPECT().GetUserByEmail(gomock.Any(), "<GIVEN_EMAIL>").Return(u, nil).AnyTimes() | ||
}, | ||
Config: ` | ||
provider slack { | ||
slack_token = "<SLACK_TOKEN>" | ||
} | ||
data "slack_user" "user_by_email" { | ||
email = "<GIVEN_EMAIL>" | ||
} | ||
`, | ||
// assert | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.slack_user.user_by_email", "id"), | ||
resource.TestCheckResourceAttrSet("data.slack_user.user_by_email", "name"), | ||
resource.TestCheckResourceAttrSet("data.slack_user.user_by_email", "email"), | ||
|
||
resource.TestCheckResourceAttrWith("data.slack_user.user_by_email", "id", testBed.ExpectString("<ID>")), | ||
resource.TestCheckResourceAttrWith("data.slack_user.user_by_email", "name", testBed.ExpectString("<NAME>")), | ||
resource.TestCheckResourceAttrWith("data.slack_user.user_by_email", "email", testBed.ExpectString("<GIVEN_EMAIL>")), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
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,21 @@ | ||
package dependencies | ||
|
||
import ( | ||
"github.com/essent/terraform-provider-slack/internal/slackExt" | ||
"github.com/slack-go/slack" | ||
) | ||
|
||
type Dependencies interface { | ||
CreateSlackClient(token string) slackExt.Client | ||
} | ||
|
||
type dependenciesImpl struct { | ||
} | ||
|
||
func (d *dependenciesImpl) CreateSlackClient(token string) slackExt.Client { | ||
return slackExt.New(slack.New(token)) | ||
} | ||
|
||
func New() Dependencies { | ||
return &dependenciesImpl{} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
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
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
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,32 @@ | ||
package testBed | ||
|
||
import "github.com/slack-go/slack" | ||
|
||
type UserBuilder struct { | ||
result *slack.User | ||
} | ||
|
||
func (b *UserBuilder) Build() *slack.User { | ||
return b.result | ||
} | ||
|
||
func (b *UserBuilder) WithID(id string) *UserBuilder { | ||
b.result.ID = id | ||
return b | ||
} | ||
|
||
func (b *UserBuilder) WithName(name string) *UserBuilder { | ||
b.result.Name = name | ||
return b | ||
} | ||
|
||
func (b *UserBuilder) WithEmail(email string) *UserBuilder { | ||
b.result.Profile.Email = email | ||
return b | ||
} | ||
|
||
func NewUserBuilder() *UserBuilder { | ||
return &UserBuilder{ | ||
result: &slack.User{}, | ||
} | ||
} |
Oops, something went wrong.