github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/ruler/storage/instance/marshal_test.go (about) 1 // This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. 2 // We cannot vendor the agent in since the agent vendors loki in, which would cause a cyclic dependency. 3 // NOTE: many changes have been made to the original code for our use-case. 4 package instance 5 6 import ( 7 "bytes" 8 "strings" 9 "testing" 10 11 "github.com/stretchr/testify/require" 12 "gopkg.in/yaml.v2" 13 ) 14 15 func TestUnmarshalConfig_Valid(t *testing.T) { 16 validConfig := DefaultConfig 17 validConfigContent, err := yaml.Marshal(validConfig) 18 require.NoError(t, err) 19 20 _, err = UnmarshalConfig(bytes.NewReader(validConfigContent)) 21 require.NoError(t, err) 22 } 23 24 func TestUnmarshalConfig_Invalid(t *testing.T) { 25 invalidConfigContent := `whyWouldAnyoneThinkThisisAValidConfig: 12345` 26 27 _, err := UnmarshalConfig(strings.NewReader(invalidConfigContent)) 28 require.Error(t, err) 29 }