File tree Expand file tree Collapse file tree 5 files changed +76
-0
lines changed Expand file tree Collapse file tree 5 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "bufio"
5+ "bytes"
6+ "io/ioutil"
7+ "os"
8+ "strings"
9+ "testing"
10+ )
11+
12+ var (
13+ inDir = "testdata/input/"
14+ outDir = "testdata/output/"
15+ )
16+
17+ func TestProcess (t * testing.T ) {
18+ files , err := ioutil .ReadDir (inDir )
19+ if err != nil {
20+ t .Errorf ("failed to read the testdata: %s" , err )
21+ }
22+
23+ for _ , file := range files {
24+ t .Run (file .Name (), func (t * testing.T ) {
25+ inpath := inDir + file .Name ()
26+ outpath := outDir + file .Name ()
27+
28+ f , err := os .Open (inpath )
29+ if err != nil {
30+ t .Errorf ("failed to load input: %s" , err )
31+ }
32+
33+ in := bufio .NewReader (f )
34+ out := & bytes.Buffer {}
35+
36+ process (in , out )
37+
38+ expectedBytes , err := ioutil .ReadFile (outpath )
39+ if err != nil {
40+ t .Errorf ("failed to load output: %s" , err )
41+ }
42+
43+ actual := out .String ()
44+ expected := string (expectedBytes )
45+ if strings .Compare (expected , actual ) != 0 {
46+ t .Errorf ("expected:\n \n %s\n but got:\n \n %s\n " , expected , actual )
47+ }
48+ })
49+ }
50+ }
Original file line number Diff line number Diff line change 1+ ./file1.yaml:4:5: [warning] comment not indented like content (comments-indentation)
2+ ./file1.yaml:5:6: [error] wrong indentation: expected 4 but found 5 (indentation)
3+ ./file2.yaml:7:5: [error] syntax error: expected <block end>, but found '<block mapping start>' (syntax)
Original file line number Diff line number Diff line change 1+ ./file1.yaml:4:5: [warning] comment not indented like content
2+ ./file1.yaml:5:6: [error] wrong indentation: expected 4 but found 5
3+ ./file2.yaml:7:5: [error] syntax error: expected <block end>, but found '<block mapping start>'
Original file line number Diff line number Diff line change 1+ <?xml version="1.0" encoding="UTF-8"?>
2+ <checkstyle version="5.0">
3+ <file name="./file1.yaml">
4+ <error line="4" column="5" severity="warning" source="comments-indentation" message="comment not indented like content"></error>
5+ <error line="5" column="6" severity="error" source="indentation" message="wrong indentation: expected 4 but found 5"></error>
6+ </file>
7+ <file name="./file2.yaml">
8+ <error line="7" column="5" severity="error" source="syntax" message="syntax error: expected <block end>, but found '<block mapping start>'"></error>
9+ </file>
10+ </checkstyle>
Original file line number Diff line number Diff line change 1+ <?xml version="1.0" encoding="UTF-8"?>
2+ <checkstyle version="5.0">
3+ <file name="./file1.yaml">
4+ <error line="4" column="5" severity="warning" message="comment not indented like content"></error>
5+ <error line="5" column="6" severity="error" message="wrong indentation: expected 4 but found 5"></error>
6+ </file>
7+ <file name="./file2.yaml">
8+ <error line="7" column="5" severity="error" message="syntax error: expected <block end>, but found '<block mapping start>'"></error>
9+ </file>
10+ </checkstyle>
You can’t perform that action at this time.
0 commit comments