2023-03-02 15:37:05 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-10 18:53:29 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-02 15:37:05 -05:00
|
|
|
|
2019-09-25 16:38:12 -04:00
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestBuildWithCleanupScript(t *testing.T) {
|
|
|
|
|
c := &BuildCommand{
|
2021-12-01 09:58:33 -05:00
|
|
|
Meta: TestMetaFile(t),
|
2019-09-25 16:38:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args := []string{
|
2020-05-08 11:46:33 -04:00
|
|
|
"-parallel-builds=1",
|
2019-09-25 16:38:12 -04:00
|
|
|
filepath.Join(testFixture("cleanup-script"), "template.json"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
|
|
// build should exit with error code!
|
|
|
|
|
if code := c.Run(args); code == 0 {
|
|
|
|
|
fatalCommand(t, c.Meta)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !fileExists("ducky.txt") {
|
|
|
|
|
t.Errorf("Expected to find ducky.txt")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|