aboutsummaryrefslogtreecommitdiff
path: root/file_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'file_test.go')
-rw-r--r--file_test.go48
1 files changed, 30 insertions, 18 deletions
diff --git a/file_test.go b/file_test.go
index 1b3823c..20110ca 100644
--- a/file_test.go
+++ b/file_test.go
@@ -11,53 +11,65 @@ import (
func TestFile_detectComment(t *testing.T) {
type testCase struct {
- topLines [][]byte
- expFile file
+ f file
+ expFile file
}
listCase := []testCase{{
- topLines: [][]byte{
- []byte(`#!/bin/sh`),
+ f: file{
+ path: `test.sh`,
+ topLines: [][]byte{
+ []byte(`#!/bin/sh`),
+ },
},
expFile: file{
+ path: `test.sh`,
+ topLines: [][]byte{
+ []byte(`#!/bin/sh`),
+ },
commentPrefix: `# `,
hasSheBang: true,
},
}, {
- topLines: [][]byte{
- []byte(`# comment`),
+ f: file{
+ path: `test.rb`,
},
expFile: file{
+ path: `test.rb`,
commentPrefix: `# `,
},
}, {
- topLines: [][]byte{
- []byte(`// comment`),
+ f: file{
+ path: `test.c`,
},
expFile: file{
+ path: `test.c`,
commentPrefix: `// `,
},
}, {
- topLines: [][]byte{
- []byte(`/*`),
+ f: file{
+ path: `test.go`,
},
expFile: file{
+ path: `test.go`,
commentPrefix: `// `,
},
}, {
- topLines: [][]byte{
- []byte(`<!--`),
+ f: file{
+ path: `test.html`,
},
expFile: file{
+ path: `test.html`,
commentPrefix: `<!-- `,
commentSuffix: ` -->`,
},
}}
+ cfg := &config{}
+ err := cfg.parse([]byte(configTemplate))
+ if err != nil {
+ t.Fatal(err)
+ }
for _, tc := range listCase {
- f := file{
- topLines: tc.topLines,
- }
- f.detectComment()
- f.topLines = nil
- test.Assert(t, string(tc.topLines[0]), tc.expFile, f)
+ tc.f.detectComment(cfg)
+ test.Assert(t, tc.f.path, tc.expFile, tc.f)
}
}