Support setting env vars in kubectl run

This commit is contained in:
feihujiang
2015-09-01 11:03:29 +08:00
parent bb3e20e361
commit 84e94e39cd
8 changed files with 198 additions and 5 deletions

View File

@@ -17,10 +17,12 @@ limitations under the License.
package cmd
import (
"reflect"
"testing"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
func TestGetRestartPolicy(t *testing.T) {
@@ -78,3 +80,20 @@ func TestGetRestartPolicy(t *testing.T) {
}
}
}
func TestGetEnv(t *testing.T) {
test := struct {
input []string
expected []string
}{
input: []string{"a=b", "c=d"},
expected: []string{"a=b", "c=d"},
}
cmd := &cobra.Command{}
cmd.Flags().StringSlice("env", test.input, "")
envStrings := cmdutil.GetFlagStringSlice(cmd, "env")
if len(envStrings) != 2 || !reflect.DeepEqual(envStrings, test.expected) {
t.Errorf("expected: %s, saw: %s", test.expected, envStrings)
}
}