MCPcopy Create free account
hub / github.com/coder/coder / TestDetectIndentUnit

Function TestDetectIndentUnit

agent/agentfiles/files_indent_internal_test.go:14–107  ·  view source on GitHub ↗

Direct unit tests for the indent-splice helpers. These test the functions in isolation so a helper bug surfaces here with a descriptive failure instead of as a rendered-file mismatch deep in an integration test.

(t *testing.T)

Source from the content-addressed store, hash-verified

12// in an integration test.
13
14func TestDetectIndentUnit(t *testing.T) {
15 t.Parallel()
16
17 tests := []struct {
18 name string
19 lines []string
20 wantUnit string
21 wantOK bool
22 }{
23 {
24 name: "Empty",
25 lines: nil,
26 wantUnit: "",
27 wantOK: false,
28 },
29 {
30 name: "NoIndent",
31 lines: []string{"foo\n", "bar\n"},
32 wantUnit: "",
33 wantOK: false,
34 },
35 {
36 name: "TabOnly",
37 lines: []string{"\tfoo\n", "\t\tbar\n"},
38 wantUnit: "\t",
39 wantOK: true,
40 },
41 {
42 name: "FourSpaceUniform",
43 lines: []string{" foo\n", " bar\n"},
44 wantUnit: " ",
45 wantOK: true,
46 },
47 {
48 name: "TwoSpaceUniform",
49 lines: []string{" foo\n", " bar\n"},
50 wantUnit: " ",
51 wantOK: true,
52 },
53 {
54 name: "GCDReducesFourAndSixToTwo",
55 lines: []string{" foo\n", " bar\n"},
56 wantUnit: " ",
57 wantOK: true,
58 },
59 {
60 name: "MixedAcrossLinesTabAndSpace",
61 lines: []string{"\tfoo\n", " bar\n"},
62 wantUnit: "",
63 wantOK: false,
64 },
65 {
66 name: "MixedWithinLeadTabThenSpace",
67 lines: []string{"\t foo\n"},
68 wantUnit: "",
69 wantOK: false,
70 },
71 {

Callers

nothing calls this directly

Calls 3

detectIndentUnitFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected