MCPcopy
hub / github.com/hashicorp/hcl / TestDiagnosticTextWriter

Function TestDiagnosticTextWriter

diagnostic_text_test.go:14–214  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestDiagnosticTextWriter(t *testing.T) {
15 tests := []struct {
16 Input *Diagnostic
17 Want string
18 }{
19 {
20 &Diagnostic{
21 Severity: DiagError,
22 Summary: "Splines not reticulated",
23 Detail: "All splines must be pre-reticulated.",
24 Subject: &Range{
25 Start: Pos{
26 Byte: 0,
27 Column: 1,
28 Line: 1,
29 },
30 End: Pos{
31 Byte: 3,
32 Column: 4,
33 Line: 1,
34 },
35 },
36 },
37 `Error: Splines not reticulated
38
39 on line 1, in hardcoded-context:
40 1: foo = 1
41
42All splines must be pre-reticulated.
43
44`,
45 },
46 {
47 &Diagnostic{
48 Severity: DiagError,
49 Summary: "Unsupported attribute",
50 Detail: `"baz" is not a supported top-level attribute. Did you mean "bam"?`,
51 Subject: &Range{
52 Start: Pos{
53 Byte: 16,
54 Column: 1,
55 Line: 3,
56 },
57 End: Pos{
58 Byte: 19,
59 Column: 4,
60 Line: 3,
61 },
62 },
63 },
64 `Error: Unsupported attribute
65
66 on line 3, in hardcoded-context:
67 3: baz = 3
68
69"baz" is not a supported top-level
70attribute. Did you mean "bam"?
71

Callers

nothing calls this directly

Calls 4

NewDiagnosticTextWriterFunction · 0.85
RunMethod · 0.80
WriteDiagnosticMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected