2018-01-12 17:30:54 +01:00
|
|
|
package fs
|
|
|
|
|
2020-12-30 14:06:43 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
2018-01-12 17:30:54 +01:00
|
|
|
|
|
|
|
// Check it satisfies the interface
|
|
|
|
var _ pflag.Value = (*LogLevel)(nil)
|
2020-12-30 14:06:43 +01:00
|
|
|
var _ fmt.Stringer = LogValueItem{}
|
|
|
|
|
|
|
|
type withString struct{}
|
|
|
|
|
|
|
|
func (withString) String() string {
|
|
|
|
return "hello"
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLogValue(t *testing.T) {
|
|
|
|
x := LogValue("x", 1)
|
|
|
|
assert.Equal(t, "1", x.String())
|
|
|
|
x = LogValue("x", withString{})
|
|
|
|
assert.Equal(t, "hello", x.String())
|
|
|
|
x = LogValueHide("x", withString{})
|
|
|
|
assert.Equal(t, "", x.String())
|
|
|
|
}
|