replace string casting with fmt.sprintf in test

in: staging/src/k8s.io/kubectl/pkg/cmd/create/create_rolebinding_test.go
test: TestCreateRoleBinding

On go version 1.15.3, casting int to string using `string(int)` causes
the test to fail with this error:

>> k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/create
vendor/k8s.io/kubectl/pkg/cmd/create/create_rolebinding_test.go:75:9:
    conversion from int to string yields a string of one rune, not a
    string of digits (did you mean fmt.Sprint(x)?)
FAIL    k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/create
    [build failed]
FAIL
make: *** [Makefile:185: test] Error 1
This commit is contained in:
Obeyda Djeffal 2020-11-04 09:51:01 +01:00
parent acc3910964
commit 1e0bbe61ae
No known key found for this signature in database
GPG Key ID: FB6AACE934B7216A

View File

@ -17,6 +17,7 @@ limitations under the License.
package create
import (
"fmt"
"testing"
rbac "k8s.io/api/rbac/v1"
@ -72,7 +73,7 @@ func TestCreateRoleBinding(t *testing.T) {
}
for i, tc := range tests {
t.Run(string(i), func(t *testing.T) {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
roleBinding, err := tc.options.createRoleBinding()
if err != nil {
t.Errorf("unexpected error:\n%#v\n", err)