Add shared-root publish planning
This commit is contained in:
@@ -200,6 +200,38 @@ func TestSharedRootOwnerOutputHelpersRejectConflicts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompareSharedRootOwnerScopesCurrentOwner(t *testing.T) {
|
||||
state := validSharedRootState(t)
|
||||
source := validManifest(t)
|
||||
source.Created = source.Created.Add(time.Hour)
|
||||
scope := CurrentOwnerScope("reports", "archive")
|
||||
|
||||
comparison := CompareSharedRootOwner(source, scope, DestinationStatus{SharedRoot: &state, HasContents: true})
|
||||
if comparison.Outcome != OutcomeDestinationOlder {
|
||||
t.Fatalf("comparison = %#v, want destination older for current owner", comparison)
|
||||
}
|
||||
|
||||
missing := CompareSharedRootOwner(source, CurrentOwnerScope("missing", "archive"), DestinationStatus{SharedRoot: &state, HasContents: true})
|
||||
if missing.Outcome != OutcomeDestinationAbsent {
|
||||
t.Fatalf("missing owner comparison = %#v, want destination absent", missing)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompareSharedRootOwnerAcceptsMatchingSingleOwnerState(t *testing.T) {
|
||||
singleOwner, err := Parse([]byte(validStateJSON(t)))
|
||||
if err != nil {
|
||||
t.Fatalf("Parse() error = %v", err)
|
||||
}
|
||||
source := singleOwner.Source.Manifest
|
||||
source.Created = source.Created.Add(time.Hour)
|
||||
scope := CurrentOwnerScope(singleOwner.PipelineID, singleOwner.DestinationID)
|
||||
|
||||
comparison := CompareSharedRootOwner(source, scope, DestinationStatus{State: &singleOwner, HasContents: true})
|
||||
if comparison.Outcome != OutcomeDestinationOlder {
|
||||
t.Fatalf("comparison = %#v, want destination older", comparison)
|
||||
}
|
||||
}
|
||||
|
||||
func validSharedRootStateJSON(t *testing.T) string {
|
||||
t.Helper()
|
||||
data, err := json.MarshalIndent(validSharedRootState(t), "", " ")
|
||||
|
||||
Reference in New Issue
Block a user