Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Oct 9, 2023
1 parent febe2bd commit a241c4a
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions internal/logx/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ func TestNewOperationLogger(t *testing.T) {
}
ol := NewOperationLogger(logger, "antani%d", 0)
ol.Stop(nil)
if len(lines) != 1 {
if len(lines) != 2 {
t.Fatal("unexpected number of lines")
}
if lines[0] != "antani0... ok" {
if lines[0] != "antani0... started" {
t.Fatal("unexpected first line", lines[0])
}
if lines[1] != "antani0... ok" {
t.Fatal("unexpected first line", lines[0])
}
})
Expand All @@ -49,10 +52,13 @@ func TestNewOperationLogger(t *testing.T) {
}
ol := NewOperationLogger(logger, "antani%d", 0)
ol.Stop(io.EOF)
if len(lines) != 1 {
if len(lines) != 2 {
t.Fatal("unexpected number of lines")
}
if lines[0] != "antani0... EOF" {
if lines[0] != "antani0... started" {
t.Fatal("unexpected first line", lines[0])
}
if lines[1] != "antani0... EOF" {
t.Fatal("unexpected first line", lines[0])
}
})
Expand All @@ -74,13 +80,16 @@ func TestNewOperationLogger(t *testing.T) {
ol := newOperationLogger(maxwait, logger, "antani%d", 0)
ol.wg.Wait() // wait for the message to be emitted
ol.Stop(nil)
if len(lines) != 2 {
if len(lines) != 3 {
t.Fatal("unexpected number of lines")
}
if lines[0] != "antani0... in progress" {
if lines[0] != "antani0... started" {
t.Fatal("unexpected first line", lines[0])
}
if lines[1] != "antani0... ok" {
if lines[1] != "antani0... in progress" {
t.Fatal("unexpected first line", lines[0])
}
if lines[2] != "antani0... ok" {
t.Fatal("unexpected first line", lines[0])
}
})
Expand All @@ -102,13 +111,16 @@ func TestNewOperationLogger(t *testing.T) {
ol := newOperationLogger(maxwait, logger, "antani%d", 0)
ol.wg.Wait() // wait for the message to be emitted
ol.Stop(io.EOF)
if len(lines) != 2 {
if len(lines) != 3 {
t.Fatal("unexpected number of lines")
}
if lines[0] != "antani0... in progress" {
if lines[0] != "antani0... started" {
t.Fatal("unexpected first line", lines[0])
}
if lines[1] != "antani0... EOF" {
if lines[1] != "antani0... in progress" {
t.Fatal("unexpected first line", lines[0])
}
if lines[2] != "antani0... EOF" {
t.Fatal("unexpected first line", lines[0])
}
})
Expand Down

0 comments on commit a241c4a

Please sign in to comment.