Skip to content

Commit 87ccd41

Browse files
committed
e2e storage: add compile test for public TestSuite API
This will catch accidentally adding a new interface function which isn't exported. For example, an attempt to implement a new unexported "foobar()" function then leads to: test/e2e/storage/testsuites/api_test.go:54:5: cannot use &fakeSuite literal (type *fakeSuite) as type testsuites.TestSuite in assignment: *fakeSuite does not implement testsuites.TestSuite (missing testsuites.foobar method) have foobar() want testsuites.foobar() FAIL k8s.io/kubernetes/test/e2e/storage/testsuites [build failed]
1 parent 160da35 commit 87ccd41

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package testsuites_test is used intentionally to ensure that the
18+
// code below only has access to exported names. It doesn't have any
19+
// actual test. That the custom volume test suite defined below
20+
// compile is the test.
21+
//
22+
// It's needed because we don't have any in-tree volume test
23+
// suite implementations that aren't in the "testuites" package itself.
24+
// We don't need this for the "TestDriver" interface because there
25+
// we have implementations in a separate package.
26+
package testsuites_test
27+
28+
import (
29+
"k8s.io/kubernetes/test/e2e/framework/volume"
30+
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
31+
"k8s.io/kubernetes/test/e2e/storage/testsuites"
32+
)
33+
34+
type fakeSuite struct {
35+
}
36+
37+
func (f *fakeSuite) GetTestSuiteInfo() testsuites.TestSuiteInfo {
38+
return testsuites.TestSuiteInfo{
39+
Name: "fake",
40+
FeatureTag: "",
41+
TestPatterns: []testpatterns.TestPattern{testpatterns.DefaultFsDynamicPV},
42+
SupportedSizeRange: volume.SizeRange{Min: "1Mi", Max: "1Gi"},
43+
}
44+
}
45+
46+
func (f *fakeSuite) DefineTests(testsuites.TestDriver, testpatterns.TestPattern) {
47+
}
48+
49+
func (f *fakeSuite) SkipRedundantSuite(testsuites.TestDriver, testpatterns.TestPattern) {
50+
}
51+
52+
var _ testsuites.TestSuite = &fakeSuite{}

0 commit comments

Comments
 (0)