Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
utahta committed Dec 29, 2017
1 parent d8c8f67 commit 786afa5
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,69 @@ func TestDebugLogger_Errorf(t *testing.T) {
t.Errorf("Expected stderr %s, got %s", errStr, ebuf.String())
}
}

func TestStdoutLogger_Write(t *testing.T) {
obuf := &bytes.Buffer{}
l := &stdoutLogger{w: obuf}
outStr := "out text"

l.Write([]byte(outStr))
if !strings.Contains(obuf.String(), outStr) {
t.Errorf("Expected stdout %s, got %s", outStr, obuf.String())
}
}

func TestStdoutLogger_Error(t *testing.T) {
ebuf := &bytes.Buffer{}
l := &stdoutLogger{w: ebuf}
errStr := "err text"

l.Error(errStr)
if !strings.Contains(ebuf.String(), errStr) {
t.Errorf("Expected stderr %s, got %s", errStr, ebuf.String())
}
}

func TestStdoutLogger_Errorf(t *testing.T) {
ebuf := &bytes.Buffer{}
l := &stdoutLogger{w: ebuf}
errStr := "err text"

l.Errorf("%s", errStr)
if !strings.Contains(ebuf.String(), errStr) {
t.Errorf("Expected stderr %s, got %s", errStr, ebuf.String())
}
}

func TestStderrLogger_Write(t *testing.T) {
obuf := &bytes.Buffer{}
l := &stderrLogger{w: obuf}
outStr := "out text"

l.Write([]byte(outStr))
if !strings.Contains(obuf.String(), outStr) {
t.Errorf("Expected stdout %s, got %s", outStr, obuf.String())
}
}

func TestStderrLogger_Error(t *testing.T) {
ebuf := &bytes.Buffer{}
l := &stderrLogger{w: ebuf}
errStr := "err text"

l.Error(errStr)
if !strings.Contains(ebuf.String(), errStr) {
t.Errorf("Expected stderr %s, got %s", errStr, ebuf.String())
}
}

func TestStderrLogger_Errorf(t *testing.T) {
ebuf := &bytes.Buffer{}
l := &stderrLogger{w: ebuf}
errStr := "err text"

l.Errorf("%s", errStr)
if !strings.Contains(ebuf.String(), errStr) {
t.Errorf("Expected stderr %s, got %s", errStr, ebuf.String())
}
}

0 comments on commit 786afa5

Please sign in to comment.