feat: apply terminal reconciliation cleanup
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
rvboxv1 "github.com/rvbox/rvbox/gen/go/rvbox/v1"
|
||||
"github.com/rvbox/rvbox/internal/agentproto"
|
||||
"github.com/rvbox/rvbox/internal/domain"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
@@ -64,11 +65,35 @@ func TestReconcileSnapshot_HP_SES_08(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyReconcileResult_HP_SES_12(t *testing.T) {
|
||||
t.Parallel()
|
||||
active := "019c46f1-1d02-7000-8000-000000000062"
|
||||
terminal := "019c46f1-1d02-7000-8000-000000000063"
|
||||
store := &reconcileStore{}
|
||||
terminated, err := ApplyReconcileResult(context.Background(), store, &rvboxv1.ReconcileResult{
|
||||
TerminateLocalIssueUuids: []string{active},
|
||||
DiscardLocalTerminalIssueUuids: []string{terminal},
|
||||
}, time.Date(2026, time.September, 6, 0, 0, 0, 0, time.UTC))
|
||||
if err != nil || len(terminated) != 1 || terminated[0].String() != active || len(store.discarded) != 1 || store.discarded[0].String() != terminal {
|
||||
t.Fatalf("ApplyReconcileResult = terminated=%v discarded=%v err=%v", terminated, store.discarded, err)
|
||||
}
|
||||
if _, err := ApplyReconcileResult(context.Background(), store, &rvboxv1.ReconcileResult{TerminateLocalIssueUuids: []string{active}, DiscardLocalTerminalIssueUuids: []string{active}}, time.Now()); !errors.Is(err, ErrInvalidReconcileResult) {
|
||||
t.Fatalf("overlapping result error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
type fakeTransport struct {
|
||||
written []byte
|
||||
read []byte
|
||||
}
|
||||
|
||||
type reconcileStore struct{ discarded []domain.UUID }
|
||||
|
||||
func (store *reconcileStore) DiscardTerminal(_ context.Context, issue domain.UUID, _ time.Time) error {
|
||||
store.discarded = append(store.discarded, issue)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (transport *fakeTransport) Write(_ context.Context, value []byte) error {
|
||||
transport.written = append([]byte(nil), value...)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user