MCPcopy
hub / github.com/hashicorp/packer / TestBuildExceptFileCommaFlags

Function TestBuildExceptFileCommaFlags

command/build_test.go:732–803  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

730}
731
732func TestBuildExceptFileCommaFlags(t *testing.T) {
733 c := &BuildCommand{
734 Meta: TestMetaFile(t),
735 }
736 tc := []struct {
737 name string
738 args []string
739 expectedFiles []string
740 buildNotExpectedFiles []string
741 postProcNotExpectedFiles []string
742 }{
743 {
744 name: "JSON: except build and post-processor",
745 args: []string{
746 "-parallel-builds=1",
747 "-except=chocolate,vanilla,tomato",
748 filepath.Join(testFixture("build-only"), "template.json"),
749 },
750 expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"},
751 buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"},
752 postProcNotExpectedFiles: []string{"pear.txt, banana.txt"},
753 },
754 {
755 name: "HCL2: except build and post-processor",
756 args: []string{
757 "-parallel-builds=1",
758 "-except=file.chocolate,file.vanilla,tomato",
759 filepath.Join(testFixture("build-only"), "template.pkr.hcl"),
760 },
761 expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"},
762 buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"},
763 postProcNotExpectedFiles: []string{"pear.txt, banana.txt"},
764 },
765 {
766 name: "HCL2-JSON: except build and post-processor",
767 args: []string{
768 "-parallel-builds=1",
769 "-except=file.chocolate,file.vanilla,tomato",
770 filepath.Join(testFixture("build-only"), "template.pkr.json"),
771 },
772 expectedFiles: []string{"apple.txt", "cherry.txt", "peach.txt"},
773 buildNotExpectedFiles: []string{"chocolate.txt", "vanilla.txt", "tomato.txt", "unnamed.txt"},
774 postProcNotExpectedFiles: []string{"pear.txt, banana.txt"},
775 },
776 }
777
778 for _, tt := range tc {
779 t.Run(tt.name, func(t *testing.T) {
780 defer cleanup()
781
782 if code := c.Run(tt.args); code != 0 {
783 fatalCommand(t, c.Meta)
784 }
785
786 for _, f := range tt.buildNotExpectedFiles {
787 if fileExists(f) {
788 t.Errorf("build not skipped: Expected NOT to find %s", f)
789 }

Callers

nothing calls this directly

Calls 8

RunMethod · 0.95
TestMetaFileFunction · 0.85
testFixtureFunction · 0.85
cleanupFunction · 0.85
fatalCommandFunction · 0.85
fileExistsFunction · 0.70
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…