gosick #1
50
script/prepare_release_script_test.go
Normal file
50
script/prepare_release_script_test.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package script_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPrepareReleaseScript_UsesVociferateReleaseprep(t *testing.T) {
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
repoRoot := filepath.Dir(wd)
|
||||||
|
tempBin := t.TempDir()
|
||||||
|
argsLog := filepath.Join(tempBin, "go-args.log")
|
||||||
|
fakeGoPath := filepath.Join(tempBin, "go")
|
||||||
|
|
||||||
|
fakeGo := `#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
printf '%s\n' "$*" > "$GO_ARGS_LOG"
|
||||||
|
`
|
||||||
|
require.NoError(t, os.WriteFile(fakeGoPath, []byte(fakeGo), 0o755))
|
||||||
|
|
||||||
|
cmd := exec.Command("bash", filepath.Join(repoRoot, "script", "prepare-release.sh"), "v1.2.3")
|
||||||
|
cmd.Dir = repoRoot
|
||||||
|
cmd.Env = append(os.Environ(),
|
||||||
|
"PATH="+tempBin+":"+os.Getenv("PATH"),
|
||||||
|
"GO_ARGS_LOG="+argsLog,
|
||||||
|
)
|
||||||
|
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
require.NoError(t, err, string(output))
|
||||||
|
|
||||||
|
invocationBytes, err := os.ReadFile(argsLog)
|
||||||
|
require.NoError(t, err)
|
||||||
|
invocation := strings.TrimSpace(string(invocationBytes))
|
||||||
|
|
||||||
|
require.Contains(t, invocation, "run git.hrafn.xyz/aether/vociferate/cmd/releaseprep@latest")
|
||||||
|
require.Contains(t, invocation, "--root "+repoRoot)
|
||||||
|
require.Contains(t, invocation, "--version v1.2.3")
|
||||||
|
require.Contains(t, invocation, "--version-file internal/homesick/version/version.go")
|
||||||
|
require.Contains(t, invocation, "--version-pattern const String = \"([^\"]+)\"")
|
||||||
|
require.Contains(t, invocation, "--changelog changelog.md")
|
||||||
|
require.Regexp(t, regexp.MustCompile(`--date [0-9]{4}-[0-9]{2}-[0-9]{2}`), invocation)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user