Skip to content

Commit 58ee530

Browse files
committed
protosanitizer: remove package dependency on CSI
The test code must be conceptually in a different package, otherwise the "protosanitizer" package depends on the CSI 1.0 package and cannot be vendored into a client relying on an older version of the spec, not even when stripping of go test code is enabled - at least "dep" checks package dependencies before stripping. The downside of moving the tests is that a manual "go test ./protosanitizer" no longer runs the test. They are still run by "make test": $ make test go test `go list ./... | grep -v ^vendor` ? github.com/kubernetes-csi/csi-lib-utils/protosanitizer [no test files] ok github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test 0.051s ? github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csi03 [no test files] ? github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csitest [no test files]
1 parent 67f76c8 commit 58ee530

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

protosanitizer/protosanitizer_test.go renamed to protosanitizer/test/protosanitizer_test.go

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

17-
package protosanitizer
17+
package protosanitizer_test
1818

1919
import (
2020
"fmt"
2121
"testing"
2222

2323
"github.com/container-storage-interface/spec/lib/go/csi"
2424
"github.com/golang/protobuf/proto"
25+
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
2526
csi03 "github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csi03"
2627
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csitest"
2728
"github.com/stretchr/testify/assert"
@@ -205,9 +206,9 @@ func TestStripSecrets(t *testing.T) {
205206
before := fmt.Sprint(c.original)
206207
var stripped fmt.Stringer
207208
if _, ok := c.original.(*csi03.CreateVolumeRequest); ok {
208-
stripped = StripSecretsCSI03(c.original)
209+
stripped = protosanitizer.StripSecretsCSI03(c.original)
209210
} else {
210-
stripped = StripSecrets(c.original)
211+
stripped = protosanitizer.StripSecrets(c.original)
211212
}
212213
if assert.Equal(t, c.stripped, fmt.Sprintf("%s", stripped), "unexpected result for fmt s of %s", c.original) {
213214
assert.Equal(t, c.stripped, fmt.Sprintf("%v", stripped), "unexpected result for fmt v of %s", c.original)
@@ -216,7 +217,7 @@ func TestStripSecrets(t *testing.T) {
216217
}
217218

218219
// The secret is hidden because StripSecrets is a struct referencing it.
219-
dump := fmt.Sprintf("%#v", StripSecrets(createVolume))
220+
dump := fmt.Sprintf("%#v", protosanitizer.StripSecrets(createVolume))
220221
assert.NotContains(t, dump, secretName)
221222
assert.NotContains(t, dump, secretValue)
222223
}

0 commit comments

Comments
 (0)