From f65146500c629d34135171b4e95a53bf823baa04 Mon Sep 17 00:00:00 2001
From: lijianguo <lijianguo@zhumengyuan.com>
Date: Mon, 16 Nov 2020 14:31:24 +0800
Subject: [PATCH] chore(ps):drycc ps:list show autoscale num

---
 api/ps.go      |  4 ++--
 api/ps_test.go | 14 +++++------
 ps/ps.go       |  2 +-
 ps/ps_test.go  | 64 +++++++++++++++++++++++++-------------------------
 4 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/api/ps.go b/api/ps.go
index 136d921..1493b4a 100644
--- a/api/ps.go
+++ b/api/ps.go
@@ -15,7 +15,7 @@ type Pods struct {
 	Name     string    `json:"name,omitempty"`
 	State    string    `json:"state,omitempty"`
 	Started  time.Time `json:"started,omitempty"`
-	Replicas int       `json:"replicas,omitempty"`
+	Replicas string    `json:"replicas,omitempty"`
 }
 
 // PodsList defines a collection of app pods.
@@ -29,7 +29,7 @@ func (p PodsList) Less(i, j int) bool { return p[i].Name < p[j].Name }
 type PodType struct {
 	Type     string
 	PodsList PodsList
-	Replicas int
+	Replicas string
 	Status   string
 }
 
diff --git a/api/ps_test.go b/api/ps_test.go
index 3c02993..e4445f6 100644
--- a/api/ps_test.go
+++ b/api/ps_test.go
@@ -9,10 +9,10 @@ import (
 
 func TestPodsListSorted(t *testing.T) {
 	pods := PodsList{
-		{"", "web", "web.fsdfgh4", "up", time.Time{}, 4},
-		{"", "web", "web.asdfgh1", "up", time.Time{}, 4},
-		{"", "web", "web.csdfgh3", "up", time.Time{}, 4},
-		{"", "web", "web.bsdfgh2", "up", time.Time{}, 4},
+		{"", "web", "web.fsdfgh4", "up", time.Time{}, "4"},
+		{"", "web", "web.asdfgh1", "up", time.Time{}, "4"},
+		{"", "web", "web.csdfgh3", "up", time.Time{}, "4"},
+		{"", "web", "web.bsdfgh2", "up", time.Time{}, "4"},
 	}
 
 	sort.Sort(pods)
@@ -28,9 +28,9 @@ func TestPodsListSorted(t *testing.T) {
 
 func TestPodTypesSorted(t *testing.T) {
 	podTypes := PodTypes{
-		{"worker", PodsList{}, 4, "started"},
-		{"web", PodsList{}, 4, "started"},
-		{"clock", PodsList{}, 4, "started"},
+		{"worker", PodsList{}, "4", "started"},
+		{"web", PodsList{}, "4", "started"},
+		{"clock", PodsList{}, "4", "started"},
 	}
 
 	sort.Sort(podTypes)
diff --git a/ps/ps.go b/ps/ps.go
index 83c315b..0fd4b38 100644
--- a/ps/ps.go
+++ b/ps/ps.go
@@ -129,7 +129,7 @@ func ByType(processes api.PodsList) api.PodTypes {
 		if !exists {
 			p := api.PodsList{process}
 			status := "started"
-			if process.State == "stopped" && process.Replicas != 0 {
+			if process.State == "stopped" && process.Replicas != "0" {
 				status = "stopped"
 			}
 			if process.Name == "" {
diff --git a/ps/ps_test.go b/ps/ps_test.go
index b6febb7..2d65c53 100644
--- a/ps/ps_test.go
+++ b/ps/ps_test.go
@@ -25,7 +25,7 @@ const processesFixture string = `
             "name": "example-go-v2-web-45678",
             "state": "up",
             "started": "2016-02-13T00:47:52",
-            "replicas": 1
+            "replicas": "1"
         }
     ]
 }`
@@ -37,7 +37,7 @@ const restartAllFixture string = `[
         "name": "example-go-v2-web-45678",
         "state": "up",
         "started": "2016-02-13T00:47:52",
-        "replicas": 1
+        "replicas": "1"
     }
 ]
 `
@@ -49,7 +49,7 @@ const restartWorkerFixture string = `[
         "name": "example-go-v2-worker-45678",
         "state": "up",
         "started": "2016-02-13T00:47:52",
-        "replicas": 1
+        "replicas": "1"
     }
 ]
 `
@@ -61,7 +61,7 @@ const restartWebTwoFixture string = `[
         "name": "example-go-v2-web-45678",
         "state": "up",
         "started": "2016-02-13T00:47:52",
-        "replicas": 1
+        "replicas": "1"
     }
 ]
 `
@@ -182,7 +182,7 @@ func TestProcessesList(t *testing.T) {
 			Name:     "example-go-v2-web-45678",
 			State:    "up",
 			Started:  started,
-			Replicas: 1,
+			Replicas: "1",
 		},
 	}
 
@@ -228,7 +228,7 @@ func TestAppsRestart(t *testing.T) {
 					Name:     "example-go-v2-web-45678",
 					State:    "up",
 					Started:  started,
-					Replicas: 1,
+					Replicas: "1",
 				},
 			},
 		},
@@ -242,7 +242,7 @@ func TestAppsRestart(t *testing.T) {
 					Name:     "example-go-v2-worker-45678",
 					State:    "up",
 					Started:  started,
-					Replicas: 1,
+					Replicas: "1",
 				},
 			},
 		},
@@ -256,7 +256,7 @@ func TestAppsRestart(t *testing.T) {
 					Name:     "example-go-v2-worker-45678",
 					State:    "up",
 					Started:  started,
-					Replicas: 1,
+					Replicas: "1",
 				},
 			},
 		},
@@ -270,7 +270,7 @@ func TestAppsRestart(t *testing.T) {
 					Name:     "example-go-v2-web-45678",
 					State:    "up",
 					Started:  started,
-					Replicas: 1,
+					Replicas: "1",
 				},
 			},
 		},
@@ -359,52 +359,52 @@ func TestByType(t *testing.T) {
 		{
 			Type: "abc",
 			PodsList: api.PodsList{
-				{Type: "abc", Name: "1", Started: started, Replicas: 3, State: "up"},
-				{Type: "abc", Name: "2", Started: started, Replicas: 3, State: "up"},
-				{Type: "abc", Name: "3", Started: started, Replicas: 3, State: "up"},
+				{Type: "abc", Name: "1", Started: started, Replicas: "3", State: "up"},
+				{Type: "abc", Name: "2", Started: started, Replicas: "3", State: "up"},
+				{Type: "abc", Name: "3", Started: started, Replicas: "3", State: "up"},
 			},
-			Replicas: 3,
+			Replicas: "3",
 			Status:   "started",
 		},
 		{
 			Type:     "job",
 			PodsList: api.PodsList{},
-			Replicas: 3,
+			Replicas: "3",
 			Status:   "stopped",
 		},
 		{
 			Type: "web",
 			PodsList: api.PodsList{
-				{Type: "web", Name: "test1", Started: started, Replicas: 3, State: "up"},
-				{Type: "web", Name: "test2", Started: started, Replicas: 3, State: "up"},
-				{Type: "web", Name: "test3", Started: started, Replicas: 3, State: "up"},
+				{Type: "web", Name: "test1", Started: started, Replicas: "3", State: "up"},
+				{Type: "web", Name: "test2", Started: started, Replicas: "3", State: "up"},
+				{Type: "web", Name: "test3", Started: started, Replicas: "3", State: "up"},
 			},
-			Replicas: 3,
+			Replicas: "3",
 			Status:   "started",
 		},
 		{
 			Type: "worker",
 			PodsList: api.PodsList{
-				{Type: "worker", Name: "a", Started: started, Replicas: 3, State: "up"},
-				{Type: "worker", Name: "b", Started: started, Replicas: 3, State: "up"},
-				{Type: "worker", Name: "c", Started: started, Replicas: 3, State: "up"},
+				{Type: "worker", Name: "a", Started: started, Replicas: "3", State: "up"},
+				{Type: "worker", Name: "b", Started: started, Replicas: "3", State: "up"},
+				{Type: "worker", Name: "c", Started: started, Replicas: "3", State: "up"},
 			},
-			Replicas: 3,
+			Replicas: "3",
 			Status:   "started",
 		},
 	}
 
 	input := api.PodsList{
-		{Type: "worker", Name: "c", Started: started, Replicas: 3, State: "up"},
-		{Type: "abc", Name: "2", Started: started, Replicas: 3, State: "up"},
-		{Type: "worker", Name: "b", Started: started, Replicas: 3, State: "up"},
-		{Type: "web", Name: "test1", Started: started, Replicas: 3, State: "up"},
-		{Type: "web", Name: "test3", Started: started, Replicas: 3, State: "up"},
-		{Type: "abc", Name: "1", Started: started, Replicas: 3, State: "up"},
-		{Type: "worker", Name: "a", Started: started, Replicas: 3, State: "up"},
-		{Type: "abc", Name: "3", Started: started, Replicas: 3, State: "up"},
-		{Type: "web", Name: "test2", Started: started, Replicas: 3, State: "up"},
-		{Type: "job", Replicas: 3, State: "stopped"},
+		{Type: "worker", Name: "c", Started: started, Replicas: "3", State: "up"},
+		{Type: "abc", Name: "2", Started: started, Replicas: "3", State: "up"},
+		{Type: "worker", Name: "b", Started: started, Replicas: "3", State: "up"},
+		{Type: "web", Name: "test1", Started: started, Replicas: "3", State: "up"},
+		{Type: "web", Name: "test3", Started: started, Replicas: "3", State: "up"},
+		{Type: "abc", Name: "1", Started: started, Replicas: "3", State: "up"},
+		{Type: "worker", Name: "a", Started: started, Replicas: "3", State: "up"},
+		{Type: "abc", Name: "3", Started: started, Replicas: "3", State: "up"},
+		{Type: "web", Name: "test2", Started: started, Replicas: "3", State: "up"},
+		{Type: "job", Replicas: "3", State: "stopped"},
 	}
 
 	actual := ByType(input)
