MCPcopy
hub / github.com/kptdev/kpt / Compare

Function Compare

internal/testutil/testutil.go:208–238  ·  view source on GitHub ↗
(t *testing.T, a, b string)

Source from the content-addressed store, hash-verified

206}
207
208func Compare(t *testing.T, a, b string) {
209 // Compare parses the yaml and serializes both files to normalize
210 // formatting
211 b1, err := ioutil.ReadFile(a)
212 if !assert.NoError(t, err) {
213 t.FailNow()
214 }
215 n1, err := yaml.Parse(string(b1))
216 if !assert.NoError(t, err) {
217 t.FailNow()
218 }
219 s1, err := n1.String()
220 if !assert.NoError(t, err) {
221 t.FailNow()
222 }
223 b2, err := ioutil.ReadFile(b)
224 if !assert.NoError(t, err) {
225 t.FailNow()
226 }
227 n2, err := yaml.Parse(string(b2))
228 if !assert.NoError(t, err) {
229 t.FailNow()
230 }
231 s2, err := n2.String()
232 if !assert.NoError(t, err) {
233 t.FailNow()
234 }
235 if !assert.Equal(t, s1, s2) {
236 t.FailNow()
237 }
238}
239
240// AssertKptfile verifies the contents of the KptFile matches the provided value.
241func (g *TestGitRepo) AssertKptfile(t *testing.T, cloned string, kpkg kptfile.KptFile) bool {

Callers 1

TestKptGetSetFunction · 0.92

Calls 1

StringMethod · 0.45

Tested by 1

TestKptGetSetFunction · 0.74