Skip to content

Fix acctests #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

// Client token, host, htpp.Client
type Client struct {
Token string
Token string
TokenHeader string
Host string
Client *http.Client
Host string
Client *http.Client
}

// RequestOptions path, method, etc
Expand All @@ -34,10 +34,10 @@ func NewClient(hostname string, token string, tokenHeader string) *Client {
tokenHeader = "Authorization"
}
return &Client{
Host: hostname,
Token: token,
Host: hostname,
Token: token,
TokenHeader: tokenHeader,
Client: &http.Client{},
Client: &http.Client{},
}

}
Expand All @@ -55,9 +55,9 @@ func (client *Client) RequestAPI(opt *RequestOptions) ([]byte, error) {

tokenHeader := client.TokenHeader
if tokenHeader == "" {
tokenHeader = "Authorization"
tokenHeader = "Authorization"
}
request.Header.Set(tokenHeader, client.Token)
request.Header.Set(tokenHeader, client.Token)
request.Header.Set("Content-Type", "application/json; charset=utf-8")

resp, err := client.Client.Do(request)
Expand Down
10 changes: 5 additions & 5 deletions client/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (client *Client) AddPendingUser(user *NewUser) (*User, error) {

// AddUserToTeamByAdmin - adds user to team with swich account
func (client *Client) AddUserToTeamByAdmin(userID string, accountID string, team string) error {
// get first accountAdmin and its token
// get first accountAdmin and its token
account, err := client.GetAccountByID(accountID)
if err != nil {
return err
Expand All @@ -131,9 +131,9 @@ func (client *Client) AddUserToTeamByAdmin(userID string, accountID string, team
accountAdminUserID := account.Admins[0]
accountAdminToken, err := client.GetXAccessToken(accountAdminUserID, accountID)
if err != nil {
return err
return err
}
// new Client for accountAdmin
// new Client for accountAdmin
accountAdminClient := NewClient(client.Host, accountAdminToken, "x-access-token")
usersTeam, err := accountAdminClient.GetTeamByName(team)
if err != nil {
Expand All @@ -152,7 +152,7 @@ func (client *Client) AddUserToTeamByAdmin(userID string, accountID string, team
}

err = accountAdminClient.AddUserToTeam(usersTeam.ID, userID)

return err
}

Expand Down Expand Up @@ -245,7 +245,7 @@ func (client *Client) GetUserByID(userId string) (*User, error) {
}
}

return nil, errors.New(fmt.Sprint("[ERROR] User with ID %s wasn't found.", userId))
return nil, errors.New(fmt.Sprintf("[ERROR] User with ID %s wasn't found.", userId))
}

func (client *Client) DeleteUser(userName string) error {
Expand Down
4 changes: 2 additions & 2 deletions codefresh/resource_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func resourceApiKey() *schema.Resource {
Required: true,
},
"token": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"scopes": {
Expand Down
6 changes: 3 additions & 3 deletions codefresh/resource_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestAccCodefreshPipeline_Tags(t *testing.T) {
Config: testAccCodefreshPipelineBasicConfigTags(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git", "testTag1", "testTag2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckCodefreshPipelineExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.3247715412", "testTag2"),
resource.TestCheckResourceAttr(resourceName, "tags.3938019223", "testTag1"),
resource.TestCheckResourceAttr(resourceName, "tags.1", "testTag2"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "testTag1"),
),
},
{
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestAccCodefreshPipeline_Variables(t *testing.T) {
func TestAccCodefreshPipeline_RuntimeEnvironment(t *testing.T) {
name := pipelineNamePrefix + acctest.RandString(10)
resourceName := "codefresh_pipeline.test"
runtimeName := "system/codefresh-inc-default"
runtimeName := "system/default"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
4 changes: 2 additions & 2 deletions codefresh/resource_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func TestAccCodefreshProject_Tags(t *testing.T) {
Config: testAccCodefreshProjectBasicConfigTags(name, "testTag1", "testTag2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckCodefreshProjectExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "tags.3247715412", "testTag2"),
resource.TestCheckResourceAttr(resourceName, "tags.3938019223", "testTag1"),
resource.TestCheckResourceAttr(resourceName, "tags.1", "testTag2"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "testTag1"),
),
},
{
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func main() {
debugMode := (os.Getenv("CODEFRESH_PLUGIN_DEBUG") != "")
// for terraform 0.13: export CODEFRESH_PLUGIN_ADDR="codefresh.io/app/codefresh"
providerAddr := os.Getenv("CODEFRESH_PLUGIN_ADDR")
providerAddr := os.Getenv("CODEFRESH_PLUGIN_ADDR")
if providerAddr == "" {
providerAddr = "registry.terraform.io/-/codefresh"
}
Expand Down