mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Adding a kubectl resource printer for deployments
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/expapi"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
|
||||
@@ -1221,3 +1222,39 @@ func TestTranslateTimestamp(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintDeployment(t *testing.T) {
|
||||
tests := []struct {
|
||||
deployment expapi.Deployment
|
||||
expect string
|
||||
}{
|
||||
{
|
||||
expapi.Deployment{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test1",
|
||||
CreationTimestamp: util.Time{Time: time.Now().Add(1.9e9)},
|
||||
},
|
||||
Spec: expapi.DeploymentSpec{
|
||||
Replicas: 5,
|
||||
Template: &api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
|
||||
},
|
||||
},
|
||||
Status: expapi.DeploymentStatus{
|
||||
Replicas: 10,
|
||||
UpdatedReplicas: 2,
|
||||
},
|
||||
},
|
||||
"test1\t2/5\t0s\n",
|
||||
},
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
for _, test := range tests {
|
||||
printDeployment(&test.deployment, buf, false, false, true, []string{})
|
||||
if buf.String() != test.expect {
|
||||
t.Fatalf("Expected: %s, got: %s", test.expect, buf.String())
|
||||
}
|
||||
buf.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user