mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #70368 from thomasem/cmd_test_to_cmd
Swap cmd_test to cmd package in kubeadm/app/cmd/config_test.go
This commit is contained in:
commit
587f020a1a
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cmd_test
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -31,7 +31,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd"
|
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||||
@ -52,7 +51,7 @@ const (
|
|||||||
func TestNewCmdConfigImagesList(t *testing.T) {
|
func TestNewCmdConfigImagesList(t *testing.T) {
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
mockK8sVersion := dummyKubernetesVersion
|
mockK8sVersion := dummyKubernetesVersion
|
||||||
images := cmd.NewCmdConfigImagesList(&output, &mockK8sVersion)
|
images := NewCmdConfigImagesList(&output, &mockK8sVersion)
|
||||||
images.Run(nil, nil)
|
images.Run(nil, nil)
|
||||||
actual := strings.Split(output.String(), "\n")
|
actual := strings.Split(output.String(), "\n")
|
||||||
if len(actual) != defaultNumberOfImages {
|
if len(actual) != defaultNumberOfImages {
|
||||||
@ -109,7 +108,7 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
|||||||
t.Fatalf("Failed writing a config file: %v", err)
|
t.Fatalf("Failed writing a config file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
i, err := cmd.NewImagesList(configFilePath, &kubeadmapiv1beta1.InitConfiguration{
|
i, err := NewImagesList(configFilePath, &kubeadmapiv1beta1.InitConfiguration{
|
||||||
ClusterConfiguration: kubeadmapiv1beta1.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapiv1beta1.ClusterConfiguration{
|
||||||
KubernetesVersion: dummyKubernetesVersion,
|
KubernetesVersion: dummyKubernetesVersion,
|
||||||
},
|
},
|
||||||
@ -180,7 +179,7 @@ func TestConfigImagesListRunWithoutPath(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
i, err := cmd.NewImagesList("", &tc.cfg)
|
i, err := NewImagesList("", &tc.cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("did not expect an error while creating the Images command: %v", err)
|
t.Fatalf("did not expect an error while creating the Images command: %v", err)
|
||||||
}
|
}
|
||||||
@ -226,7 +225,7 @@ func TestImagesPull(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
images := []string{"a", "b", "c", "d", "a"}
|
images := []string{"a", "b", "c", "d", "a"}
|
||||||
ip := cmd.NewImagesPull(containerRuntime, images)
|
ip := NewImagesPull(containerRuntime, images)
|
||||||
|
|
||||||
err = ip.PullAll()
|
err = ip.PullAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -249,7 +248,7 @@ func TestMigrate(t *testing.T) {
|
|||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
command := cmd.NewCmdConfigMigrate(&output)
|
command := NewCmdConfigMigrate(&output)
|
||||||
if err := command.Flags().Set("old-config", configFile); err != nil {
|
if err := command.Flags().Set("old-config", configFile); err != nil {
|
||||||
t.Fatalf("failed to set old-config flag")
|
t.Fatalf("failed to set old-config flag")
|
||||||
}
|
}
|
||||||
@ -293,7 +292,7 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
|
|||||||
constants.ClusterConfigurationKind,
|
constants.ClusterConfigurationKind,
|
||||||
constants.InitConfigurationKind,
|
constants.InitConfigurationKind,
|
||||||
},
|
},
|
||||||
cmdProc: cmd.NewCmdConfigPrintInitDefaults,
|
cmdProc: NewCmdConfigPrintInitDefaults,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "InitConfiguration: KubeProxyConfiguration",
|
name: "InitConfiguration: KubeProxyConfiguration",
|
||||||
@ -303,7 +302,7 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
|
|||||||
string(componentconfigs.KubeProxyConfigurationKind),
|
string(componentconfigs.KubeProxyConfigurationKind),
|
||||||
},
|
},
|
||||||
componentConfigs: "KubeProxyConfiguration",
|
componentConfigs: "KubeProxyConfiguration",
|
||||||
cmdProc: cmd.NewCmdConfigPrintInitDefaults,
|
cmdProc: NewCmdConfigPrintInitDefaults,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "InitConfiguration: KubeProxyConfiguration and KubeletConfiguration",
|
name: "InitConfiguration: KubeProxyConfiguration and KubeletConfiguration",
|
||||||
@ -314,14 +313,14 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
|
|||||||
string(componentconfigs.KubeletConfigurationKind),
|
string(componentconfigs.KubeletConfigurationKind),
|
||||||
},
|
},
|
||||||
componentConfigs: "KubeProxyConfiguration,KubeletConfiguration",
|
componentConfigs: "KubeProxyConfiguration,KubeletConfiguration",
|
||||||
cmdProc: cmd.NewCmdConfigPrintInitDefaults,
|
cmdProc: NewCmdConfigPrintInitDefaults,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "JoinConfiguration: No component configs",
|
name: "JoinConfiguration: No component configs",
|
||||||
expectedKinds: []string{
|
expectedKinds: []string{
|
||||||
constants.JoinConfigurationKind,
|
constants.JoinConfigurationKind,
|
||||||
},
|
},
|
||||||
cmdProc: cmd.NewCmdConfigPrintJoinDefaults,
|
cmdProc: NewCmdConfigPrintJoinDefaults,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "JoinConfiguration: KubeProxyConfiguration",
|
name: "JoinConfiguration: KubeProxyConfiguration",
|
||||||
@ -330,7 +329,7 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
|
|||||||
string(componentconfigs.KubeProxyConfigurationKind),
|
string(componentconfigs.KubeProxyConfigurationKind),
|
||||||
},
|
},
|
||||||
componentConfigs: "KubeProxyConfiguration",
|
componentConfigs: "KubeProxyConfiguration",
|
||||||
cmdProc: cmd.NewCmdConfigPrintJoinDefaults,
|
cmdProc: NewCmdConfigPrintJoinDefaults,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "JoinConfiguration: KubeProxyConfiguration and KubeletConfiguration",
|
name: "JoinConfiguration: KubeProxyConfiguration and KubeletConfiguration",
|
||||||
@ -340,7 +339,7 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
|
|||||||
string(componentconfigs.KubeletConfigurationKind),
|
string(componentconfigs.KubeletConfigurationKind),
|
||||||
},
|
},
|
||||||
componentConfigs: "KubeProxyConfiguration,KubeletConfiguration",
|
componentConfigs: "KubeProxyConfiguration,KubeletConfiguration",
|
||||||
cmdProc: cmd.NewCmdConfigPrintJoinDefaults,
|
cmdProc: NewCmdConfigPrintJoinDefaults,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user