-
Notifications
You must be signed in to change notification settings - Fork 30
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
Correct reading of state during update #125 #132
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution, @Noel-Jones!
This is looking good code-wise, but could you also ensure there is a covering acceptance test? This helps us prevent potential regressions in the future. An example test might apply a configuration with one rotation value as a first step, then update the rotation values as a second step. Something like this in internal/provider/resource_time_rotating_test.go
might get you close:
func TestAccTimeRotating_RotationDays_ToRotationMonths(t *testing.T) {
resourceName := "time_rotating.test"
timestamp := time.Now().UTC()
resource.UnitTest(t, resource.TestCase{
ProtoV5ProviderFactories: protoV5ProviderFactories(),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: testAccConfigTimeRotatingRotationDays(timestamp.Format(time.RFC3339), 7),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "rotation_days", "7"),
resource.TestCheckResourceAttr(resourceName, "rotation_rfc3339", timestamp.AddDate(0, 0, 7).Format(time.RFC3339)),
resource.TestCheckNoResourceAttr(resourceName, "rotation_years"),
resource.TestCheckNoResourceAttr(resourceName, "rotation_months"),
resource.TestCheckNoResourceAttr(resourceName, "rotation_hours"),
resource.TestCheckNoResourceAttr(resourceName, "rotation_minutes"),
resource.TestCheckResourceAttrSet(resourceName, "rfc3339"),
),
},
{
Config: testAccConfigTimeRotatingRotationMonths(timestamp.Format(time.RFC3339), 3),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "rotation_months", "3"),
resource.TestCheckResourceAttr(resourceName, "rotation_rfc3339", timestamp.AddDate(0, 3, 0).Format(time.RFC3339)),
resource.TestCheckNoResourceAttr(resourceName, "rotation_years"),
resource.TestCheckNoResourceAttr(resourceName, "rotation_days"),
resource.TestCheckNoResourceAttr(resourceName, "rotation_hours"),
resource.TestCheckNoResourceAttr(resourceName, "rotation_minutes"),
resource.TestCheckResourceAttrSet(resourceName, "rfc3339"),
),
},
},
})
}
The testing can than be run with make testacc
or TF_ACC=1 go test -count=1 -run='' -v ./internal/provider
. It should hopefully not pass without the update and pass with the update.
Please reach out if you are not able to add this or have any questions. Thanks again!
Thanks Selena. I'd wanted to add a test but still feeling my way around the way it all works. I appreciate the full detail and partuculary the (now obvious) way to run them! Ran the test before and after. Before results were a fail:
|
Please can we get an update on when this will be released into v0.9.0? |
@kevinbasoftcat we're planning on releasing early next week |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Community Note
Relates #125