summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Henidak (Kal) <khnidk@outlook.com>2021-02-18 09:42:52 -0800
committerGitHub <noreply@github.com>2021-02-18 09:42:52 -0800
commitd67ae0845eaa87c4f25e50d6f601b440b4f1b9b1 (patch)
tree10d76cb8d22174f88016ee6d796878deaa69a190
parent27d2698a2634222b259614a8f389911f99e665cb (diff)
minor update to api_changes to highlight gate on/off scenario (#5521)
* minor update to api_changes to highlight gate on/off scenario * Update contributors/devel/sig-architecture/api_changes.md Co-authored-by: Jordan Liggitt <jordan@liggitt.net> * Update contributors/devel/sig-architecture/api_changes.md Co-authored-by: Jordan Liggitt <jordan@liggitt.net> * Update contributors/devel/sig-architecture/api_changes.md Co-authored-by: Jordan Liggitt <jordan@liggitt.net> * Update contributors/devel/sig-architecture/api_changes.md Co-authored-by: Jordan Liggitt <jordan@liggitt.net> * Update contributors/devel/sig-architecture/api_changes.md Co-authored-by: Jordan Liggitt <jordan@liggitt.net> Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
-rw-r--r--contributors/devel/sig-architecture/api_changes.md33
1 files changed, 32 insertions, 1 deletions
diff --git a/contributors/devel/sig-architecture/api_changes.md b/contributors/devel/sig-architecture/api_changes.md
index c5d7442d..16b7117d 100644
--- a/contributors/devel/sig-architecture/api_changes.md
+++ b/contributors/devel/sig-architecture/api_changes.md
@@ -955,7 +955,38 @@ The recommended place to do this is in the REST storage strategy's PrepareForCre
}
```
-4. In validation, validate the field if present:
+4. To future-proof your API testing, when testing with feature gate on and off, ensure that the gate is deliberately set as desired. Don't assume that gate is off or on. As your feature
+progresses from `alpha` to `beta` and then `stable` the feature might be turned on or off by default across the entire code base. The below example
+provides some details
+
+ ```go
+ func TestAPI(t *testing.T){
+ testCases:= []struct{
+ // ... test definition ...
+ }{
+ {
+ // .. test case ..
+ },
+ {
+ // ... test case ..
+ },
+ }
+
+ for _, testCase := range testCases{
+ t.Run("..name...", func(t *testing.T){
+ // run with gate on
+ defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features. Frobber2D, true)()
+ // ... test logic ...
+ })
+ t.Run("..name...", func(t *testing.T){
+ // run with gate off, *do not assume it is off by default*
+ defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features. Frobber2D, false)()
+ // ... test gate-off testing logic logic ...
+ })
+ }
+ ```
+
+5. In validation, validate the field if present:
```go
func ValidateFrobber(f *api.Frobber, fldPath *field.Path) field.ErrorList {