MCPcopy Index your code
hub / github.com/docker/docker-agent / TestParseExamplesAfterMarshalling

Function TestParseExamplesAfterMarshalling

pkg/config/examples_test.go:108–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestParseExamplesAfterMarshalling(t *testing.T) {
109 t.Parallel()
110
111 for _, file := range collectExamples(t) {
112 t.Run(file, func(t *testing.T) {
113 t.Parallel()
114
115 cfg, err := Load(t.Context(), NewFileSource(file))
116 require.NoError(t, err)
117
118 // Make sure that a config can be marshalled and parsed again.
119 // We've had marshalling issues in the past.
120 buf, err := yaml.Marshal(cfg)
121 require.NoError(t, err)
122
123 // The marshalled bytes are always YAML, so re-load them under a
124 // .yaml-named source even when the original example was HCL.
125 name := strings.TrimSuffix(file, filepath.Ext(file)) + ".yaml"
126 _, err = Load(t.Context(), NewBytesSource(name, buf))
127 require.NoError(t, err)
128 })
129 }
130}
131
132// TestHCLExamplesMatchYAML verifies that every .hcl example file produces a
133// configuration identical to its .yaml sibling, ensuring the HCL surface

Callers

nothing calls this directly

Calls 6

NewFileSourceFunction · 0.85
NewBytesSourceFunction · 0.85
ContextMethod · 0.80
collectExamplesFunction · 0.70
LoadFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected