-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently there's no way to define precise ignore rules, like `regex` rule for specific repository and file. This PR refactors these rules in order to make them more flexible.
- Loading branch information
1 parent
fd01e5e
commit bcfeb94
Showing
4 changed files
with
138 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package config | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
"encoding/json" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestReadmeExample(t *testing.T) { | ||
data, err := os.ReadFile("../../README.md") | ||
if err != nil { | ||
t.Fatal(err, "failed to read README.md") | ||
} | ||
scan := bufio.NewScanner(bytes.NewReader(data)) | ||
readJSON := false | ||
jsonBuilder := bytes.Buffer{} | ||
for scan.Scan() { | ||
line := strings.TrimSpace(scan.Text()) | ||
switch { | ||
case line == "```json5": | ||
readJSON = true | ||
case line == "```": | ||
readJSON = false | ||
case readJSON && !strings.HasPrefix(line, "//"): | ||
jsonBuilder.WriteString(line) | ||
jsonBuilder.WriteString("\n") | ||
} | ||
} | ||
if err = scan.Err(); err != nil { | ||
t.Fatal(err, "failed to scan README.md contents") | ||
} | ||
var config Config | ||
if err = json.Unmarshal(jsonBuilder.Bytes(), &config); err != nil { | ||
t.Fatal(err, "failed to unmarshal JSON config") | ||
} | ||
if err = config.validate(); err != nil { | ||
t.Fatal(err, "config validation failed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters