Report temporary metadata cleanup failures
This commit is contained in:
@@ -54,6 +54,31 @@ func TestTagOperationsAcceptFullSlashContainingRefs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateAnnotatedTagReportsTemporaryCleanupFailure(t *testing.T) {
|
||||
fixture := newRemoteFixture(t)
|
||||
cleanupErr := errors.New("cleanup failed")
|
||||
var removed string
|
||||
remove := func(path string) error {
|
||||
removed = path
|
||||
if err := os.Remove(path); err != nil {
|
||||
return err
|
||||
}
|
||||
return cleanupErr
|
||||
}
|
||||
object, err := createAnnotatedTag(t.Context(), fixture.work, "v1.2.3", fixture.commit, []byte("note\n"), remove)
|
||||
if !errors.Is(err, cleanupErr) || object == "" || removed == "" || !strings.Contains(err.Error(), removed) {
|
||||
t.Fatalf("tag object = %q, cleanup path = %q, error = %v", object, removed, err)
|
||||
}
|
||||
if got := gitText(t, fixture.work, "rev-parse", "refs/tags/v1.2.3"); got != object {
|
||||
t.Fatalf("local tag = %q, want %q", got, object)
|
||||
}
|
||||
_, err = createAnnotatedTag(t.Context(), fixture.work, "v1.2.3", fixture.commit, []byte("note\n"), remove)
|
||||
var exit *exec.ExitError
|
||||
if !errors.As(err, &exit) || !errors.Is(err, cleanupErr) {
|
||||
t.Fatalf("tag creation and cleanup error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTagReferenceValidationUsesGitRules(t *testing.T) {
|
||||
fixture := newRemoteFixture(t)
|
||||
for _, tag := range []string{"", "v1..2.3", "v1.2.3.lock", "v1.2.3/", "v1.2.3\\bad"} {
|
||||
|
||||
Reference in New Issue
Block a user