Preflight comparison transaction names
This commit is contained in:
@@ -506,6 +506,49 @@ func TestPublishReplacesEmptyDirectory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparisonDestinationPreflightsTransactionSiblingNames(t *testing.T) {
|
||||
workingDirectory := t.TempDir()
|
||||
missingParent := filepath.Join(workingDirectory, "missing")
|
||||
target := filepath.Join(missingParent, strings.Repeat("a", maxComparisonComponentBytes+1))
|
||||
if _, err := PlanDestination(workingDirectory, target, false); err == nil {
|
||||
t.Fatal("PlanDestination() accepted an overlong destination name")
|
||||
}
|
||||
if _, err := os.Lstat(missingParent); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("missing parent stat error = %v, want not exist", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublishSupportsLongestDestinationComponent(t *testing.T) {
|
||||
workingDirectory := t.TempDir()
|
||||
parent := filepath.Join(workingDirectory, "nested")
|
||||
target := filepath.Join(parent, strings.Repeat("a", maxComparisonComponentBytes))
|
||||
|
||||
plan, err := PlanDestination(workingDirectory, target, false)
|
||||
if err != nil {
|
||||
t.Fatalf("PlanDestination() error = %v", err)
|
||||
}
|
||||
if _, err := Publish(context.Background(), plan, testBundle()); err != nil {
|
||||
t.Fatalf("Publish() error = %v", err)
|
||||
}
|
||||
if _, err := RecognizeBundle(target); err != nil {
|
||||
t.Fatalf("RecognizeBundle() error = %v", err)
|
||||
}
|
||||
|
||||
next := testBundle()
|
||||
next.Reports[0].Markdown = []byte("# Replacement\n")
|
||||
plan, err = PlanDestination(workingDirectory, target, true)
|
||||
if err != nil {
|
||||
t.Fatalf("PlanDestination(replace) error = %v", err)
|
||||
}
|
||||
if _, err := Publish(context.Background(), plan, next); err != nil {
|
||||
t.Fatalf("Publish(replace) error = %v", err)
|
||||
}
|
||||
if data := readFile(t, filepath.Join(target, "01-weather-light.md")); string(data) != "# Replacement\n" {
|
||||
t.Fatalf("replacement report = %q", data)
|
||||
}
|
||||
assertOnlyDestinationEntry(t, parent, filepath.Base(target))
|
||||
}
|
||||
|
||||
func TestPublishReportsCommittedBundleWhenBackupCleanupFails(t *testing.T) {
|
||||
workingDirectory := t.TempDir()
|
||||
target := filepath.Join(workingDirectory, "comparison-daily")
|
||||
|
||||
Reference in New Issue
Block a user