github.com/hamersaw/flytestdlib@v0.2.28/version/version_test.go (about)

     1  package version
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"testing"
     7  	"time"
     8  
     9  	"github.com/magiconair/properties/assert"
    10  	"github.com/sirupsen/logrus"
    11  )
    12  
    13  type dFormat struct {
    14  }
    15  
    16  func (dFormat) Format(e *logrus.Entry) ([]byte, error) {
    17  	return []byte(e.Message), nil
    18  }
    19  
    20  func TestLogBuildInformation(t *testing.T) {
    21  
    22  	n := time.Now()
    23  	BuildTime = n.String()
    24  	buf := bytes.NewBufferString("")
    25  	logrus.SetFormatter(dFormat{})
    26  	logrus.SetOutput(buf)
    27  	LogBuildInformation("hello")
    28  	assert.Equal(t, buf.String(), fmt.Sprintf("------------------------------------------------------------------------App [hello], Version [unknown], BuildSHA [unknown], BuildTS [%s]------------------------------------------------------------------------", n.String()))
    29  }