Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Sep 27, 2023
1 parent 61437b9 commit c5c91d1
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions env0/resource_cost_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func TestUnitAwsCostCredentialsResource(t *testing.T) {
accessor := resourceAccessor(resourceType, resourceName)

awsCredentialResource := map[string]interface{}{
"name": "test",
"arn": "11111",
"name": "test",
"arn": "11111",
"duration": 7200,
}

updatedAwsCredentialResource := map[string]interface{}{
Expand All @@ -28,10 +29,17 @@ func TestUnitAwsCostCredentialsResource(t *testing.T) {
"duration": 3600,
}

invalidDurationAwsCredentialResource := map[string]interface{}{
"name": "update",
"arn": "33333",
"duration": 1234,
}

awsCredCreatePayload := client.AwsCredentialsCreatePayload{
Name: awsCredentialResource["name"].(string),
Value: client.AwsCredentialsValuePayload{
RoleArn: awsCredentialResource["arn"].(string),
RoleArn: awsCredentialResource["arn"].(string),
Duration: awsCredentialResource["duration"].(int),
},
Type: client.AwsCostCredentialsType,
}
Expand Down Expand Up @@ -67,7 +75,7 @@ func TestUnitAwsCostCredentialsResource(t *testing.T) {
resource.TestCheckResourceAttr(accessor, "name", awsCredentialResource["name"].(string)),
resource.TestCheckResourceAttr(accessor, "arn", awsCredentialResource["arn"].(string)),
resource.TestCheckResourceAttr(accessor, "id", "id"),
resource.TestCheckNoResourceAttr(accessor, "duration"),
resource.TestCheckResourceAttr(accessor, "duration", strconv.Itoa(awsCredentialResource["duration"].(int))),
),
},
},
Expand All @@ -81,7 +89,7 @@ func TestUnitAwsCostCredentialsResource(t *testing.T) {
resource.TestCheckResourceAttr(accessor, "name", awsCredentialResource["name"].(string)),
resource.TestCheckResourceAttr(accessor, "arn", awsCredentialResource["arn"].(string)),
resource.TestCheckResourceAttr(accessor, "id", returnValues.Id),
resource.TestCheckNoResourceAttr(accessor, "duration"),
resource.TestCheckResourceAttr(accessor, "duration", strconv.Itoa(awsCredentialResource["duration"].(int))),
),
},
{
Expand Down Expand Up @@ -135,6 +143,18 @@ func TestUnitAwsCostCredentialsResource(t *testing.T) {
})
})

t.Run("throw error when don't enter duration valid values", func(t *testing.T) {
runUnitTest(t, resource.TestCase{
Steps: []resource.TestStep{
{
Config: resourceConfigCreate(resourceType, resourceName, invalidDurationAwsCredentialResource),
ExpectError: regexp.MustCompile("Error: must be one of"),
},
},
}, func(mock *client.MockApiClientInterface) {
})
})

}

func TestUnitAzureCostCredentialsResource(t *testing.T) {
Expand Down

0 comments on commit c5c91d1

Please sign in to comment.