summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-12 01:13:29 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-12 01:13:29 -0400
commitf56b11101ec68121924f20c96f6daa3981850a46 (patch)
tree0e02eba5c2de9feb9fadc63a9883bdc78f82533d
parentc18d944f6f53152ddcda3c707571f17307054e48 (diff)
downloadgetwtxt-f56b11101ec68121924f20c96f6daa3981850a46.tar.gz
testing simple error log function
-rw-r--r--svc/init_test.go15
1 files changed, 15 insertions, 0 deletions
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())
+		}
+	})
+}