...

Source file src/github.com/datawire/ambassador/v2/pkg/busy/busy_test.go

Documentation: github.com/datawire/ambassador/v2/pkg/busy

     1  package busy
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	//nolint:depguard // This is one of the few places where it is approrpiate to not go through
    10  	// dlog: to initialize dlog.
    11  	"github.com/sirupsen/logrus"
    12  )
    13  
    14  func TestLoggingTextFormatterDefault(t *testing.T) {
    15  	os.Unsetenv("AMBASSADOR_JSON_LOGGING")
    16  	testInit()
    17  
    18  	fm, isTextFormatter := logrusLogger.Formatter.(*logrus.TextFormatter)
    19  	if !assert.True(t, isTextFormatter) {
    20  		return
    21  	}
    22  	assert.Equal(t, "2006-01-02 15:04:05.0000", fm.TimestampFormat)
    23  	assert.True(t, fm.FullTimestamp)
    24  }
    25  
    26  func TestLoggingJsonFormatter(t *testing.T) {
    27  	os.Setenv("AMBASSADOR_JSON_LOGGING", "true")
    28  	testInit()
    29  
    30  	fm, isJSONFormatter := logrusLogger.Formatter.(*logrus.JSONFormatter)
    31  	if !assert.True(t, isJSONFormatter) {
    32  		return
    33  	}
    34  	assert.Equal(t, "2006-01-02 15:04:05.0000", fm.TimestampFormat)
    35  }
    36  

View as plain text