Skip to content

Commit

Permalink
Beta Example Tests
Browse files Browse the repository at this point in the history
This PR runs example tests of beta and stable features under the feature flag
`enable-api-fields: beta`. This is an extension to PR
#5737.
  • Loading branch information
chitrangpatel authored and tekton-robot committed Feb 23, 2023
1 parent e535adb commit 0b5e88e
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 313 deletions.
6 changes: 6 additions & 0 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12443,6 +12443,12 @@ string
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.TaskRunConditionType">TaskRunConditionType
(<code>string</code> alias)</h3>
<div>
<p>TaskRunConditionType is an enum used to store TaskRun custom conditions
conditions such as one used in spire results verification</p>
</div>
<h3 id="tekton.dev/v1beta1.TaskRunDebug">TaskRunDebug
</h3>
<p>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shurcooL/githubv4 v0.0.0-20190718010115-4ba037080260 // indirect
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.1
github.com/vbatts/tar-split v0.11.2 // indirect
Expand Down
12 changes: 10 additions & 2 deletions test/path_filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func getPathFilter(t *testing.T) (pathFilter, error) {
f = stablePathFilter
case "alpha":
f = alphaPathFilter
case "beta":
f = betaPathFilter
}
if f == nil {
return nil, fmt.Errorf("unable to create path filter from feature gate %q", enabledFeatureGate)
Expand Down Expand Up @@ -90,11 +92,17 @@ func getFeatureGate(namespace string) (string, error) {
// stablePathFilter returns true for any example that should be allowed to run
// when "enable-api-fields" is "stable".
func stablePathFilter(p string) bool {
return !(strings.Contains(p, "/alpha/") || strings.Contains(p, "/beta/"))
return !strings.Contains(p, "/alpha/") && !strings.Contains(p, "/beta/")
}

// alphaPathFilter returns true for any example that should be allowed to run
// when "enable-api-fields" is "alpha".
func alphaPathFilter(p string) bool {
return strings.Contains(p, "/alpha/") || strings.Contains(p, "/beta/") || stablePathFilter(p)
return true
}

// betaPathFilter returns true for any example that should be allowed to run
// when "enable-api-fields" is "beta".
func betaPathFilter(p string) bool {
return !strings.Contains(p, "/alpha/")
}
47 changes: 47 additions & 0 deletions test/path_filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,50 @@ func TestAlphaPathFilter(t *testing.T) {
})
}
}

func TestBetaPathFilter(t *testing.T) {
for _, tc := range []struct {
path string
allowed bool
}{{
path: "/test.yaml",
allowed: true,
}, {
path: "/alpha/test.yaml",
allowed: false,
}, {
path: "/beta/test.yaml",
allowed: true,
}, {
path: "/foo/test.yaml",
allowed: true,
}, {
path: "/v1alpha1/taskruns/test.yaml",
allowed: true,
}, {
path: "/v1alpha1/taskruns/alpha/test.yaml",
allowed: false,
}, {
path: "/v1beta1/taskruns/test.yaml",
allowed: true,
}, {
path: "/v1beta1/taskruns/alpha/test.yaml",
allowed: false,
}, {
path: "/v1beta1/taskruns/alpha/test.yaml",
allowed: false,
}, {
path: "/v1alpha1/pipelineruns/beta/test.yaml",
allowed: true,
}, {
path: "/v1alpha1/pipelineruns/beta/test.yaml",
allowed: true,
}} {
name := strings.Replace(tc.path, "/", " ", -1)
t.Run(name, func(t *testing.T) {
if got := betaPathFilter(tc.path); got != tc.allowed {
t.Errorf("path %q: want %t got %t", tc.path, tc.allowed, got)
}
})
}
}
27 changes: 0 additions & 27 deletions third_party/LICENSE

This file was deleted.

202 changes: 0 additions & 202 deletions third_party/crypto/internal/boring/LICENSE

This file was deleted.

27 changes: 0 additions & 27 deletions third_party/vendor/golang.org/x/crypto/LICENSE

This file was deleted.

27 changes: 0 additions & 27 deletions third_party/vendor/golang.org/x/net/LICENSE

This file was deleted.

Loading

0 comments on commit 0b5e88e

Please sign in to comment.