github.com/weaveworks/common@v0.0.0-20230728070032-dd9e68f319d5/logging/level_test.go (about) 1 package logging 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 "gopkg.in/yaml.v2" 8 ) 9 10 func TestMarshalYAML(t *testing.T) { 11 var l Level 12 err := l.Set("debug") 13 require.NoError(t, err) 14 15 // Test the non-pointed to Level, as people might embed it. 16 y, err := yaml.Marshal(l) 17 require.NoError(t, err) 18 require.Equal(t, []byte("debug\n"), y) 19 20 // And the pointed to Level. 21 y, err = yaml.Marshal(&l) 22 require.NoError(t, err) 23 require.Equal(t, []byte("debug\n"), y) 24 }