mirror of https://github.com/docker/cli.git
removed logging from command/formatter package tests
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
This commit is contained in:
parent
eb7452cf3a
commit
7f71d0d979
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestContainerPsContext(t *testing.T) {
|
func TestContainerPsContext(t *testing.T) {
|
||||||
|
@ -357,12 +358,11 @@ func TestContainerContextWriteJSON(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := json.Unmarshal([]byte(line), &m); err != nil {
|
err := json.Unmarshal([]byte(line), &m)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, expectedJSONs[i], m, msg)
|
||||||
assert.Equal(t, expectedJSONs[i], m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,12 +377,11 @@ func TestContainerContextWriteJSONField(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var s string
|
var s string
|
||||||
if err := json.Unmarshal([]byte(line), &s); err != nil {
|
err := json.Unmarshal([]byte(line), &s)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, containers[i].ID, s, msg)
|
||||||
assert.Equal(t, containers[i].ID, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package formatter
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -10,6 +11,7 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNetworkContext(t *testing.T) {
|
func TestNetworkContext(t *testing.T) {
|
||||||
|
@ -183,12 +185,11 @@ func TestNetworkContextWriteJSON(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := json.Unmarshal([]byte(line), &m); err != nil {
|
err := json.Unmarshal([]byte(line), &m)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, expectedJSONs[i], m, msg)
|
||||||
assert.Equal(t, expectedJSONs[i], m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,11 +204,10 @@ func TestNetworkContextWriteJSONField(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var s string
|
var s string
|
||||||
if err := json.Unmarshal([]byte(line), &s); err != nil {
|
err := json.Unmarshal([]byte(line), &s)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, networks[i].ID, s, msg)
|
||||||
assert.Equal(t, networks[i].ID, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package formatter
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ import (
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNodeContext(t *testing.T) {
|
func TestNodeContext(t *testing.T) {
|
||||||
|
@ -248,12 +250,11 @@ func TestNodeContextWriteJSON(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := json.Unmarshal([]byte(line), &m); err != nil {
|
err := json.Unmarshal([]byte(line), &m)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, testcase.expected[i], m, msg)
|
||||||
assert.Equal(t, testcase.expected[i], m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,12 +270,11 @@ func TestNodeContextWriteJSONField(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var s string
|
var s string
|
||||||
if err := json.Unmarshal([]byte(line), &s); err != nil {
|
err := json.Unmarshal([]byte(line), &s)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, nodes[i].ID, s, msg)
|
||||||
assert.Equal(t, nodes[i].ID, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,13 @@ package formatter
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServiceContextWrite(t *testing.T) {
|
func TestServiceContextWrite(t *testing.T) {
|
||||||
|
@ -200,12 +202,11 @@ func TestServiceContextWriteJSON(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := json.Unmarshal([]byte(line), &m); err != nil {
|
err := json.Unmarshal([]byte(line), &m)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, expectedJSONs[i], m, msg)
|
||||||
assert.Equal(t, expectedJSONs[i], m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestServiceContextWriteJSONField(t *testing.T) {
|
func TestServiceContextWriteJSONField(t *testing.T) {
|
||||||
|
@ -229,11 +230,10 @@ func TestServiceContextWriteJSONField(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var s string
|
var s string
|
||||||
if err := json.Unmarshal([]byte(line), &s); err != nil {
|
err := json.Unmarshal([]byte(line), &s)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, services[i].Spec.Name, s, msg)
|
||||||
assert.Equal(t, services[i].Spec.Name, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,14 @@ package formatter
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestVolumeContext(t *testing.T) {
|
func TestVolumeContext(t *testing.T) {
|
||||||
|
@ -153,12 +155,11 @@ func TestVolumeContextWriteJSON(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := json.Unmarshal([]byte(line), &m); err != nil {
|
err := json.Unmarshal([]byte(line), &m)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, expectedJSONs[i], m, msg)
|
||||||
assert.Equal(t, expectedJSONs[i], m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +174,10 @@ func TestVolumeContextWriteJSONField(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
|
||||||
t.Logf("Output: line %d: %s", i, line)
|
msg := fmt.Sprintf("Output: line %d: %s", i, line)
|
||||||
var s string
|
var s string
|
||||||
if err := json.Unmarshal([]byte(line), &s); err != nil {
|
err := json.Unmarshal([]byte(line), &s)
|
||||||
t.Fatal(err)
|
require.NoError(t, err, msg)
|
||||||
}
|
assert.Equal(t, volumes[i].Name, s, msg)
|
||||||
assert.Equal(t, volumes[i].Name, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue