mirror of
https://github.com/docker/compose.git
synced 2025-07-28 16:14:06 +02:00
improved test
Signed-off-by: keitosuwahara <keitosuwahara0816@gmail.com>
This commit is contained in:
parent
3c8da0afee
commit
8e29a138aa
@ -44,19 +44,21 @@ func TestJsonWriter_Event(t *testing.T) {
|
|||||||
}
|
}
|
||||||
w.Event(event)
|
w.Event(event)
|
||||||
|
|
||||||
var msg jsonMessage
|
var actual jsonMessage
|
||||||
err := json.Unmarshal(out.Bytes(), &msg)
|
err := json.Unmarshal(out.Bytes(), &actual)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, true, msg.DryRun)
|
expected := jsonMessage{
|
||||||
assert.Equal(t, false, msg.Tail)
|
DryRun: true,
|
||||||
assert.Equal(t, "service1", msg.ID)
|
ID: event.ID,
|
||||||
assert.Equal(t, "project", msg.ParentID)
|
ParentID: event.ParentID,
|
||||||
assert.Equal(t, "Creating", msg.Text)
|
Text: event.Text,
|
||||||
assert.Equal(t, "Working", msg.Status)
|
Status: event.StatusText,
|
||||||
assert.Equal(t, int64(50), msg.Current)
|
Current: event.Current,
|
||||||
assert.Equal(t, int64(100), msg.Total)
|
Total: event.Total,
|
||||||
assert.Equal(t, 50, msg.Percent)
|
Percent: event.Percent,
|
||||||
|
}
|
||||||
|
assert.DeepEqual(t, expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJsonWriter_TailMsgf(t *testing.T) {
|
func TestJsonWriter_TailMsgf(t *testing.T) {
|
||||||
@ -75,13 +77,13 @@ func TestJsonWriter_TailMsgf(t *testing.T) {
|
|||||||
|
|
||||||
w.Stop()
|
w.Stop()
|
||||||
|
|
||||||
var msg jsonMessage
|
var actual jsonMessage
|
||||||
err := json.Unmarshal(out.Bytes(), &msg)
|
err := json.Unmarshal(out.Bytes(), &actual)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, false, msg.DryRun)
|
expected := jsonMessage{
|
||||||
assert.Equal(t, true, msg.Tail)
|
Tail: true,
|
||||||
assert.Equal(t, "hello world", msg.Text)
|
Text: "hello world",
|
||||||
assert.Equal(t, "", msg.ID)
|
}
|
||||||
assert.Equal(t, "", msg.Status)
|
assert.DeepEqual(t, expected, actual)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user