Skip to content

Commit

Permalink
fix: vcctl unit test ci failed
Browse files Browse the repository at this point in the history
Signed-off-by: googs1025 <[email protected]>
  • Loading branch information
googs1025 committed Sep 5, 2024
1 parent 009748e commit a8a2990
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pkg/cli/jobflow/jobflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"reflect"
"strings"
"testing"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand All @@ -49,7 +50,7 @@ func TestListJobFlow(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "test-jobflow",
Namespace: "default",
CreationTimestamp: metav1.Now(),
CreationTimestamp: metav1.Time{Time: time.Now().UTC().AddDate(0, 0, -3)},
},
Status: flowv1alpha1.JobFlowStatus{
State: flowv1alpha1.State{
Expand All @@ -62,7 +63,7 @@ func TestListJobFlow(t *testing.T) {
Namespace: "default",
ExpectedErr: nil,
ExpectedOutput: `Name Namespace Phase Age
test-jobflow default Succeed 0s`,
test-jobflow default Succeed 3d`,
},
}
for _, testCase := range testCases {
Expand Down
17 changes: 9 additions & 8 deletions pkg/cli/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"reflect"
"strings"
"testing"
"time"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -58,7 +59,7 @@ func TestListPod(t *testing.T) {
JobName: "",
ExpectedErr: nil,
ExpectedOutput: `Name Ready Status Restart Age
my-pod 0/1 Running 0 0s`,
my-pod 0/1 Running 0 3d`,
},
{
name: "Normal Case with namespace filter",
Expand All @@ -72,7 +73,7 @@ my-pod 0/1 Running 0 0s`,
JobName: "",
ExpectedErr: nil,
ExpectedOutput: `Name Ready Status Restart Age
my-pod 0/1 Running 0 0s`,
my-pod 0/1 Running 0 3d`,
},
{
name: "Normal Case with jobName filter",
Expand All @@ -86,7 +87,7 @@ my-pod 0/1 Running 0 0s`,
JobName: "my-job1",
ExpectedErr: nil,
ExpectedOutput: `Name Ready Status Restart Age
my-pod 0/1 Running 0 0s`,
my-pod 0/1 Running 0 3d`,
},
{
name: "Normal Case with queueName filter",
Expand All @@ -104,9 +105,9 @@ my-pod 0/1 Running 0 0s`,
QueueName: "my-queue1",
ExpectedErr: nil,
ExpectedOutput: `Name Ready Status Restart Age
my-pod1 0/1 Running 0 0s
my-pod2 0/1 Running 0 0s
my-pod3 0/1 Running 0 0s`,
my-pod1 0/1 Running 0 3d
my-pod2 0/1 Running 0 3d
my-pod3 0/1 Running 0 3d`,
},
{
name: "Normal Case with queueName filter and jobName filter",
Expand All @@ -121,7 +122,7 @@ my-pod3 0/1 Running 0 0s`,
JobName: "my-job1",
ExpectedErr: nil,
ExpectedOutput: `Name Ready Status Restart Age
my-pod1 0/1 Running 0 0s`,
my-pod1 0/1 Running 0 3d`,
},
{
name: "Normal Case with queueName filter and jobName filter, and does not match",
Expand Down Expand Up @@ -202,7 +203,7 @@ func buildPod(namespace, name string, labels map[string]string, annotations map[
Namespace: namespace,
Labels: labels,
Annotations: annotations,
CreationTimestamp: metav1.Now(),
CreationTimestamp: metav1.Time{Time: time.Now().UTC().AddDate(0, 0, -3)},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand Down

0 comments on commit a8a2990

Please sign in to comment.