From f56b11101ec68121924f20c96f6daa3981850a46 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Wed, 12 Jun 2019 01:13:29 -0400 Subject: testing simple error log function --- svc/init_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'svc/init_test.go') diff --git a/svc/init_test.go b/svc/init_test.go index 7ddd563..0c417b4 100644 --- a/svc/init_test.go +++ b/svc/init_test.go @@ -1,12 +1,14 @@ package svc // import "github.com/getwtxt/getwtxt/svc" import ( + "bytes" "fmt" "log" "net" "os" "strings" "sync" + "testing" "github.com/getwtxt/registry" "github.com/spf13/viper" @@ -115,3 +117,16 @@ func killStatuses() { user.Mu.Unlock() twtxtCache.Mu.Unlock() } + +func Test_errLog(t *testing.T) { + t.Run("Log to Buffer", func(t *testing.T) { + b := []byte{} + buf := bytes.NewBuffer(b) + log.SetOutput(buf) + err := fmt.Errorf("test error") + errLog("", err) + if !strings.Contains(buf.String(), "test error") { + t.Errorf("Output Incorrect: %#v\n", buf.String()) + } + }) +} -- cgit 1.4.1-2-gfad0