github.com/hashicorp/packer@v1.14.3/command/build_cleanup_script_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package command
     5  
     6  import (
     7  	"path/filepath"
     8  	"testing"
     9  )
    10  
    11  func TestBuildWithCleanupScript(t *testing.T) {
    12  	c := &BuildCommand{
    13  		Meta: TestMetaFile(t),
    14  	}
    15  
    16  	args := []string{
    17  		"-parallel-builds=1",
    18  		filepath.Join(testFixture("cleanup-script"), "template.json"),
    19  	}
    20  
    21  	defer cleanup()
    22  
    23  	// build should exit with error code!
    24  	if code := c.Run(args); code == 0 {
    25  		fatalCommand(t, c.Meta)
    26  	}
    27  
    28  	if !fileExists("ducky.txt") {
    29  		t.Errorf("Expected to find ducky.txt")
    30  	}
    31  
    32  }