MCPcopy Index your code
hub / github.com/coder/coder / compareTables

Function compareTables

cli/cliui/table_test.go:487–508  ·  view source on GitHub ↗

compareTables normalizes the incoming table lines

(t *testing.T, expected, out string)

Source from the content-addressed store, hash-verified

485
486// compareTables normalizes the incoming table lines
487func compareTables(t *testing.T, expected, out string) {
488 t.Helper()
489
490 expectedLines := strings.Split(strings.TrimSpace(expected), "\n")
491 gotLines := strings.Split(strings.TrimSpace(out), "\n")
492 assert.Equal(t, len(expectedLines), len(gotLines), "expected line count does not match generated line count")
493
494 // Map the expected and got lines to normalize them.
495 expectedNormalized := make([]string, len(expectedLines))
496 gotNormalized := make([]string, len(gotLines))
497 normalizeLine := func(s string) string {
498 return strings.Join(strings.Fields(strings.TrimSpace(s)), " ")
499 }
500 for i, s := range expectedLines {
501 expectedNormalized[i] = normalizeLine(s)
502 }
503 for i, s := range gotLines {
504 gotNormalized[i] = normalizeLine(s)
505 }
506
507 require.Equal(t, expectedNormalized, gotNormalized, "expected lines to match generated lines")
508}

Callers 1

Test_DisplayTableFunction · 0.85

Calls 3

HelperMethod · 0.65
FieldsMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected