Fix WhoAmI flaky test
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> Kubernetes-commit: 378d7f8f2b05b9228efd71e73562a29f941f968a
This commit is contained in:
parent
36d5aa982d
commit
f55dcb2100
|
@ -20,6 +20,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
authenticationv1alpha1 "k8s.io/api/authentication/v1alpha1"
|
||||
|
@ -191,7 +192,14 @@ func printTableSelfSubjectAccessReview(obj runtime.Object, out io.Writer) error
|
|||
}
|
||||
|
||||
if len(ui.Extra) > 0 {
|
||||
for k, v := range ui.Extra {
|
||||
sortedKeys := make([]string, 0, len(ui.Extra))
|
||||
for k := range ui.Extra {
|
||||
sortedKeys = append(sortedKeys, k)
|
||||
}
|
||||
sort.Strings(sortedKeys)
|
||||
|
||||
for _, k := range sortedKeys {
|
||||
v := ui.Extra[k]
|
||||
_, err := fmt.Fprintf(w, "Extra: %s\t%v\n", k, v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot write an extra: %w", err)
|
||||
|
|
|
@ -53,8 +53,8 @@ func TestWhoAmIRun(t *testing.T) {
|
|||
`Username jane.doe`,
|
||||
`UID uniq-id`,
|
||||
`Groups [students teachers]`,
|
||||
`Extra: subjects [math sports]`,
|
||||
`Extra: skills [reading learning]`,
|
||||
`Extra: subjects [math sports]`,
|
||||
``,
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue