mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-10-10 04:53:09 +08:00
56064d1981
- Share one admitted lifecycle policy between regular and archive links. - Reject and release links that combine TTL caching with owned resources. - Keep wrapper clones independent from the source cache expiration. - Cover reuse, reference, invalidation, conflict, and clone behavior. Co-authored-by: nostalume <nostalucent@gmail.com> Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
26 lines
538 B
Go
26 lines
538 B
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestLinkCloneTransfersOwnershipWithoutCachePolicy(t *testing.T) {
|
|
ttl := time.Minute
|
|
source := &Link{URL: "https://example.test/file", Expiration: &ttl}
|
|
|
|
clone := source.Clone()
|
|
if clone.URL != source.URL {
|
|
t.Fatal("clone did not preserve transport data")
|
|
}
|
|
if clone.Expiration != nil {
|
|
t.Fatal("clone inherited source cache policy")
|
|
}
|
|
if err := clone.Close(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !source.Expired() {
|
|
t.Fatal("closing clone did not release its source")
|
|
}
|
|
}
|