Skip to content

Commit ca3e3ba

Browse files
authored
helper/resource: Add (testing.T).Logf() call and augment documentation for TestStep.SkipFunc (#889)
Reference: #824 Reference: https://pkg.go.dev/testing#T.Logf The additional logging will be more visible, as it will appear in stdout instead of disabled by default. The documentation updates should make the purpose and correct usage of this field more clear.
1 parent 6de4ff0 commit ca3e3ba

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.changelog/889.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
helper/resource: Added more visible logging for test steps skipped via the `TestStep` type `SkipFunc` field.
3+
```

helper/resource/testing.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,15 @@ type TestStep struct {
452452
// are tested alongside real resources
453453
PreventPostDestroyRefresh bool
454454

455-
// SkipFunc is called before applying config, but after PreConfig
456-
// This is useful for defining test steps with platform-dependent checks
455+
// SkipFunc enables skipping the TestStep, based on environment criteria.
456+
// For example, this can prevent running certain steps that may be runtime
457+
// platform or API configuration dependent.
458+
//
459+
// Return true with no error to skip the test step. The error return
460+
// should be used to signify issues that prevented the function from
461+
// completing as expected.
462+
//
463+
// SkipFunc is called after PreConfig but before applying the Config.
457464
SkipFunc func() (bool, error)
458465

459466
//---------------------------------------------------------------

helper/resource/testing_new.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ func runNewTest(t testing.T, c TestCase, helper *plugintest.Helper) {
109109
t.Fatal(err)
110110
}
111111
if skip {
112-
log.Printf("[WARN] Skipping step %d/%d", i+1, len(c.Steps))
112+
t.Logf("Skipping step %d/%d due to SkipFunc", i+1, len(c.Steps))
113+
log.Printf("[WARN] Skipping step %d/%d due to SkipFunc", i+1, len(c.Steps))
113114
continue
114115
}
115116
}

0 commit comments

Comments
 (0)