diff --git a/cfg/stringify.go b/cfg/types.go similarity index 95% rename from cfg/stringify.go rename to cfg/types.go index 555cb20e5f..28c1b0af01 100644 --- a/cfg/stringify.go +++ b/cfg/types.go @@ -35,8 +35,8 @@ func (o *Octal) UnmarshalText(text []byte) error { return nil } -func (o *Octal) MarshalText() (text []byte, err error) { - return []byte(strconv.FormatInt(int64(*o), 8)), nil +func (o Octal) MarshalText() (text []byte, err error) { + return []byte(strconv.FormatInt(int64(o), 8)), nil } // Protocol is the datatype that specifies the type of connection: http1/http2/grpc. diff --git a/cfg/stringify_test.go b/cfg/types_test.go similarity index 84% rename from cfg/stringify_test.go rename to cfg/types_test.go index 20d869ce66..511f3bd4ab 100644 --- a/cfg/stringify_test.go +++ b/cfg/types_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestOctalFieldInConfigStringify(t *testing.T) { +func TestOctalTypeInConfigStringify(t *testing.T) { c := Config{ FileSystem: FileSystemConfig{ DirMode: 0755, @@ -31,15 +31,15 @@ func TestOctalFieldInConfigStringify(t *testing.T) { str, err := util.Stringify(&c) if assert.NoError(t, err) { - assert.Equal(t, "", str) + assert.Equal(t, "file-system:\n dir-mode: \"755\"\n", str) } } func TestOctalStringify(t *testing.T) { o := Octal(0765) - str, err := util.Stringify(o) + str, err := util.Stringify(&o) if assert.NoError(t, err) { - assert.Equal(t, `"765"`, str) + assert.Equal(t, "\"765\"\n", str) } }