Skip to content

Commit

Permalink
add tests and address some PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lliissoonngg committed Jan 23, 2024
1 parent 099fb08 commit 19caa0d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func InitFlags(command *cobra.Command) {
command.Flags().StringP("in", "i", "", "Template `string` to process (alternative to --file and --input-dir)")
command.Flags().String("input-dir", "", "`directory` which is examined recursively for templates (alternative to --file and --in)")

command.Flags().StringSlice("exclude", []string{}, "glob of files to ignore")
command.Flags().StringSlice("exclude", []string{}, "glob of files to not parse")
command.Flags().StringSlice("exclude-processing", []string{}, "glob of files to be copied without parsing")
command.Flags().StringSlice("include", []string{}, "glob of files to parse")

Expand Down
31 changes: 31 additions & 0 deletions internal/tests/integration/gomplateignore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,34 @@ func TestGomplateignore_WithIncludes(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, fromSlashes("rules/index.csv"), files)
}

func TestGomplateignore_WithExcludeProcessing(t *testing.T) {
files, err := executeOpts(t, `.gomplateignore
*.log
`, []string{
"--exclude-processing", "crash.bin",
"--exclude-processing", "log/*.zip",
"--exclude", "rules/*.txt",
"--exclude", "sprites/*.ini",
},
tfs.WithDir("logs",
tfs.WithFile("archive.zip", ""),
tfs.WithFile("engine.log", ""),
tfs.WithFile("skills.log", "")),
tfs.WithDir("rules",
tfs.WithFile("index.csv", ""),
tfs.WithFile("fire.txt", ""),
tfs.WithFile("earth.txt", "")),
tfs.WithDir("sprites",
tfs.WithFile("human.csv", ""),
tfs.WithFile("demon.xml", ""),
tfs.WithFile("alien.ini", "")),
tfs.WithFile("manifest.json", ""),
tfs.WithFile("crash.bin", ""),
)

require.NoError(t, err)
assert.Equal(t, fromSlashes(
"crash.bin", "logs/archive.zip", "manifest.json", "rules/index.csv",
"sprites/demon.xml", "sprites/human.csv"), files)
}
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func readInFile(ctx context.Context, cfg *config.Config, inFile string, mode os.

source = string(b)
}
return
return source, newmode, err
}

func getOutfileHandler(ctx context.Context, cfg *config.Config, outFile string, mode os.FileMode, modeOverride bool) (io.Writer, error) {
Expand Down

0 comments on commit 19caa0d

Please sign in to comment.