Skip to content

Commit 4030fee

Browse files
committed
pkg: Move kepctl testdata to repo package
Signed-off-by: Stephen Augustus <[email protected]>
1 parent acf0d4d commit 4030fee

File tree

13 files changed

+19
-16
lines changed

13 files changed

+19
-16
lines changed

pkg/repo/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (r *Repo) Query(opts *QueryOpts) error {
117117
// load the KEPs for each listed SIG
118118
for _, sig := range opts.Groups {
119119
// KEPs in the local filesystem
120-
allKEPs = append(allKEPs, r.loadLocalKEPs(sig)...)
120+
allKEPs = append(allKEPs, r.LoadLocalKEPs(sig)...)
121121

122122
// Open PRs; existing KEPs with open PRs will be shown twice
123123
if opts.IncludePRs {

pkg/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (r *Repo) findLocalKEPMeta(sig string) ([]string, error) {
224224
return keps, err
225225
}
226226

227-
func (r *Repo) loadLocalKEPs(sig string) []*api.Proposal {
227+
func (r *Repo) LoadLocalKEPs(sig string) []*api.Proposal {
228228
// KEPs in the local filesystem
229229
files, err := r.findLocalKEPMeta(sig)
230230
if err != nil {

pkg/kepctl/kepctl_test.go renamed to pkg/repo/repo_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package kepctl
17+
package repo_test
1818

1919
import (
2020
"fmt"
@@ -25,6 +25,7 @@ import (
2525
"gopkg.in/yaml.v3"
2626

2727
"k8s.io/enhancements/api"
28+
"k8s.io/enhancements/pkg/repo"
2829
)
2930

3031
func TestValidate(t *testing.T) {
@@ -34,12 +35,12 @@ func TestValidate(t *testing.T) {
3435
err error
3536
}{
3637
{
37-
name: "valid kep passes valdiate",
38+
name: "valid KEP passes validate",
3839
file: "testdata/valid-kep.yaml",
3940
err: nil,
4041
},
4142
{
42-
name: "invalid kep fails valdiate for owning-sig",
43+
name: "invalid KEP fails validate for owning-sig",
4344
file: "testdata/invalid-kep.yaml",
4445
err: fmt.Errorf(`kep is invalid: error validating KEP metadata: "owning-sig" must be one of (committee-code-of-conduct,committee-product-security,committee-steering,sig-api-machinery,sig-apps,sig-architecture,sig-auth,sig-autoscaling,sig-cli,sig-cloud-provider,sig-cluster-lifecycle,sig-contributor-experience,sig-docs,sig-instrumentation,sig-multicluster,sig-network,sig-node,sig-release,sig-scalability,sig-scheduling,sig-security,sig-service-catalog,sig-storage,sig-testing,sig-ui,sig-usability,sig-windows,ug-big-data,ug-vmware-users,wg-api-expression,wg-component-standard,wg-data-protection,wg-iot-edge,wg-k8s-infra,wg-lts,wg-multitenancy,wg-naming,wg-policy,wg-security-audit) but it is a string: sig-awesome`),
4546
},
@@ -49,10 +50,12 @@ func TestValidate(t *testing.T) {
4950
t.Run(tc.name, func(t *testing.T) {
5051
b, err := ioutil.ReadFile(tc.file)
5152
require.NoError(t, err)
53+
5254
var p api.Proposal
5355
err = yaml.Unmarshal(b, &p)
5456
require.NoError(t, err)
55-
err = validateKEP(&p)
57+
58+
err = p.Validate()
5659
if tc.err == nil {
5760
require.NoError(t, err)
5861
} else {
@@ -77,15 +80,16 @@ func TestFindLocalKEPs(t *testing.T) {
7780
},
7881
}
7982

80-
c, clientErr := New("testdata")
81-
require.Nil(t, clientErr)
83+
r, repoErr := repo.New("testdata")
84+
require.Nil(t, repoErr)
8285

8386
for i, tc := range testcases {
84-
k := c.loadLocalKEPs("testdata", tc.sig)
87+
k := r.LoadLocalKEPs(tc.sig)
8588
if len(k) != len(tc.keps) {
8689
t.Errorf("Test case %d: expected %d but got %d", i, len(tc.keps), len(k))
8790
continue
8891
}
92+
8993
for j, kn := range k {
9094
if kn.Name != tc.keps[j] {
9195
t.Errorf("Test case %d: expected %s but got %s", i, tc.keps[j], kn.Name)

pkg/kepctl/testdata/invalid-kep.yaml renamed to pkg/repo/testdata/invalid-kep.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ approvers:
1515
creation-date: 2020-04-14
1616
last-updated: 2020-04-15
1717
stage: "alpha"
18-
status: provisional
18+
status: provisional
File renamed without changes.

pkg/kepctl/testdata/keps/sig-architecture/123-newstyle/kep.yaml renamed to pkg/repo/testdata/keps/NNNN-kep-template/kep.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ approvers:
1212
- "@mikedanese"
1313
- "@deads2k"
1414
- "@liggitt"
15-
stage: "alpha"
1615
creation-date: 2020-04-14
1716
last-updated: 2020-04-15
18-
status: provisional
17+
stage: "alpha"
18+
status: provisional
File renamed without changes.

pkg/kepctl/testdata/templates/kep.yaml renamed to pkg/repo/testdata/keps/sig-architecture/123-newstyle/kep.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ approvers:
1212
- "@mikedanese"
1313
- "@deads2k"
1414
- "@liggitt"
15+
stage: "alpha"
1516
creation-date: 2020-04-14
1617
last-updated: 2020-04-15
17-
stage: "alpha"
18-
status: provisional
18+
status: provisional
File renamed without changes.

0 commit comments

Comments
 (0)