Validate representative ReleaseKit consumers
This commit is contained in:
@@ -99,9 +99,28 @@ func TestCheckCommandBindsConfiguredChecksToCapturedCandidate(t *testing.T) {
|
||||
|
||||
func TestPublishCommandPublishesConfiguredCandidate(t *testing.T) {
|
||||
repository := newCLIRepository(t)
|
||||
writeRepositoryFile(t, repository, "docs/releases/v1.2.3.md", "# Example Product v1.2.3\n\n## Compatibility\n\nNo action required.\n")
|
||||
writeRepositoryFile(t, repository, "scripts/check-release-note.sh", `#!/bin/sh
|
||||
set -eu
|
||||
version=$RELEASEKIT_VERSION
|
||||
candidate=$RELEASEKIT_CANDIDATE
|
||||
test "$(git rev-parse HEAD)" = "$candidate"
|
||||
test "$(sed -n '1p' "docs/releases/$version.md")" = "# Example Product $version"
|
||||
grep -Fxq '## Compatibility' "docs/releases/$version.md"
|
||||
grep -Fxq 'No action required.' "docs/releases/$version.md"
|
||||
grep -Fxq 'module example.com/cli-candidate' go.mod
|
||||
printf '%s %s\n' "$version" "$candidate" >> "$RELEASEKIT_COMPATIBILITY_LOG"
|
||||
`)
|
||||
cliGitRun(t, repository, "add", "docs/releases/v1.2.3.md", "scripts/check-release-note.sh")
|
||||
cliGitRun(t, repository, "commit", "-m", "add compatibility note and check")
|
||||
checkLog := filepath.Join(t.TempDir(), "compatibility-check.log")
|
||||
settings := cli.Settings{
|
||||
Product: "Example Product",
|
||||
Remote: "origin",
|
||||
Checks: []cli.CheckCommand{{
|
||||
Args: []string{"sh", "scripts/check-release-note.sh"},
|
||||
Env: map[string]string{"RELEASEKIT_COMPATIBILITY_LOG": checkLog},
|
||||
}},
|
||||
}
|
||||
contents, err := json.Marshal(settings)
|
||||
if err != nil {
|
||||
@@ -133,6 +152,13 @@ func TestPublishCommandPublishesConfiguredCandidate(t *testing.T) {
|
||||
if got := cliGitOutput(t, remote, "rev-parse", "refs/tags/v1.2.3"); got != tagObject {
|
||||
t.Fatalf("remote tag object = %s, want %s", got, tagObject)
|
||||
}
|
||||
checkResult, err := os.ReadFile(checkLog)
|
||||
if err != nil {
|
||||
t.Fatalf("read product compatibility check result: %v", err)
|
||||
}
|
||||
if got, want := strings.Count(string(checkResult), "v1.2.3 "+commit), 1; got != want {
|
||||
t.Fatalf("product compatibility check ran %d times, want %d", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildCommandWritesValidatedReceiptForConfiguredArtifacts(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user