-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from g4s8/i26
fix: un-escape glob patterns
- Loading branch information
Showing
6 changed files
with
113 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
//go:generate go run ../ -output all.md -dir . -files * -types * | ||
//go:generate go run ../ -debug -output all.md -dir . -files * -types='*' | ||
package main |
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,64 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
t.Run("parse flags", func(t *testing.T) { | ||
var c Config | ||
fs := flag.NewFlagSet("test", flag.ContinueOnError) | ||
os.Args = []string{ | ||
"test", | ||
"-types", "foo,bar", | ||
"-files", "*", | ||
"-output", "out.txt", | ||
"-format", "plaintext", | ||
"-env-prefix", "FOO", | ||
"-no-styles", | ||
"-field-names", | ||
"-debug", | ||
} | ||
if err := c.parseFlags(fs); err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
if c.TypeGlob != "foo,bar" { | ||
t.Errorf("unexpected TypeGlob: %q", c.TypeGlob) | ||
} | ||
if c.FileGlob != "*" { | ||
t.Errorf("unexpected FileGlob: %q", c.FileGlob) | ||
} | ||
if c.OutFile != "out.txt" { | ||
t.Errorf("unexpected OutFile: %q", c.OutFile) | ||
} | ||
if c.OutFormat != "plaintext" { | ||
t.Errorf("unexpected OutFormat: %q", c.OutFormat) | ||
} | ||
if c.EnvPrefix != "FOO" { | ||
t.Errorf("unexpected EnvPrefix: %q", c.EnvPrefix) | ||
} | ||
if !c.NoStyles { | ||
t.Error("unexpected NoStyles: false") | ||
} | ||
if !c.FieldNames { | ||
t.Error("unexpected FieldNames: false") | ||
} | ||
if !c.Debug { | ||
t.Error("unexpected Debug: false") | ||
} | ||
}) | ||
t.Run("normalize", func(t *testing.T) { | ||
var c Config | ||
c.TypeGlob = `"foo"` | ||
c.FileGlob = `"*"` | ||
c.normalize() | ||
if c.TypeGlob != "foo" { | ||
t.Errorf("unexpected TypeGlob: %q", c.TypeGlob) | ||
} | ||
if c.FileGlob != "*" { | ||
t.Errorf("unexpected FileGlob: %q", c.FileGlob) | ||
} | ||
}) | ||
} |
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