|
|
@@ -161,15 +161,19 @@ func TestContextMetrics(t *testing.T) {
|
|
|
s.Start()
|
|
|
defer s.Stop()
|
|
|
|
|
|
- t.Run("do not send metrics on help commands", func(t *testing.T) {
|
|
|
+ t.Run("send metrics on help commands", func(t *testing.T) {
|
|
|
s.ResetUsage()
|
|
|
|
|
|
+ c.RunDockerCmd("help", "run")
|
|
|
c.RunDockerCmd("--help")
|
|
|
- c.RunDockerCmd("ps", "--help")
|
|
|
c.RunDockerCmd("run", "--help")
|
|
|
|
|
|
usage := s.GetUsage()
|
|
|
- assert.Equal(t, 0, len(usage))
|
|
|
+ assert.DeepEqual(t, []string{
|
|
|
+ `{"command":"help run","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"--help","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"--help run","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ }, usage)
|
|
|
})
|
|
|
|
|
|
t.Run("metrics on default context", func(t *testing.T) {
|
|
|
@@ -180,10 +184,11 @@ func TestContextMetrics(t *testing.T) {
|
|
|
c.RunDockerOrExitError("version", "--xxx")
|
|
|
|
|
|
usage := s.GetUsage()
|
|
|
- assert.Equal(t, 3, len(usage))
|
|
|
- assert.Equal(t, `{"command":"ps","context":"moby","source":"cli","status":"success"}`, usage[0])
|
|
|
- assert.Equal(t, `{"command":"version","context":"moby","source":"cli","status":"success"}`, usage[1])
|
|
|
- assert.Equal(t, `{"command":"version","context":"moby","source":"cli","status":"failure"}`, usage[2])
|
|
|
+ assert.DeepEqual(t, []string{
|
|
|
+ `{"command":"ps","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"version","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"version","context":"moby","source":"cli","status":"failure"}`,
|
|
|
+ }, usage)
|
|
|
})
|
|
|
|
|
|
t.Run("metrics on other context type", func(t *testing.T) {
|
|
|
@@ -198,14 +203,15 @@ func TestContextMetrics(t *testing.T) {
|
|
|
c.RunDockerCmd("--context", "test-example", "ps")
|
|
|
|
|
|
usage := s.GetUsage()
|
|
|
- assert.Equal(t, 7, len(usage))
|
|
|
- assert.Equal(t, `{"command":"context create","context":"moby","source":"cli","status":"success"}`, usage[0])
|
|
|
- assert.Equal(t, `{"command":"ps","context":"moby","source":"cli","status":"success"}`, usage[1])
|
|
|
- assert.Equal(t, `{"command":"context use","context":"moby","source":"cli","status":"success"}`, usage[2])
|
|
|
- assert.Equal(t, `{"command":"ps","context":"example","source":"cli","status":"success"}`, usage[3])
|
|
|
- assert.Equal(t, `{"command":"stop","context":"example","source":"cli","status":"failure"}`, usage[4])
|
|
|
- assert.Equal(t, `{"command":"context use","context":"example","source":"cli","status":"success"}`, usage[5])
|
|
|
- assert.Equal(t, `{"command":"ps","context":"example","source":"cli","status":"success"}`, usage[6])
|
|
|
+ assert.DeepEqual(t, []string{
|
|
|
+ `{"command":"context create","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"ps","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"context use","context":"moby","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"ps","context":"example","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"stop","context":"example","source":"cli","status":"failure"}`,
|
|
|
+ `{"command":"context use","context":"example","source":"cli","status":"success"}`,
|
|
|
+ `{"command":"ps","context":"example","source":"cli","status":"success"}`,
|
|
|
+ }, usage)
|
|
|
})
|
|
|
}
|
|
|
|