@@ -3,11 +3,7 @@ package header
33import (
44 "testing"
55
6- "github.com/google/uuid"
76 "github.com/stretchr/testify/assert"
8- "github.com/stretchr/testify/require"
9-
10- "github.com/e2b-dev/infra/packages/shared/pkg/storage"
117)
128
139func TestIsZero (t * testing.T ) {
@@ -26,51 +22,3 @@ func TestIsZero(t *testing.T) {
2622 buf [RootfsBlockSize - 2 ] = 0xFF
2723 assert .False (t , IsZero (buf ), "non-zero just before the last sampled byte" )
2824}
29-
30- // newDiffHeader must carry forward ancestors the source knows about and
31- // backfill the uncompressed sentinel for ones it lacks, so a legacy ancestor
32- // resolves via GetBuildFrameData (no doomed proactive header load) while the
33- // still-unuploaded self build stays absent.
34- func TestNewDiffHeaderBackfillsAncestors (t * testing.T ) {
35- t .Parallel ()
36-
37- const bs = 4096
38- self := uuid .New ()
39- knownAncestor := uuid .New ()
40- legacyAncestor := uuid .New ()
41-
42- mapping := []BuildMap {
43- {Offset : 0 , Length : bs , BuildId : self , BuildStorageOffset : 0 },
44- {Offset : bs , Length : bs , BuildId : knownAncestor , BuildStorageOffset : 0 },
45- {Offset : 2 * bs , Length : bs , BuildId : legacyAncestor , BuildStorageOffset : 0 },
46- {Offset : 3 * bs , Length : bs , BuildId : uuid .Nil , BuildStorageOffset : 0 },
47- }
48-
49- // Parent header carries only knownAncestor; legacyAncestor predates per-build
50- // headers and is absent from the source.
51- sourceBuilds := map [uuid.UUID ]BuildData {knownAncestor : {Size : 123 }}
52-
53- meta := & Metadata {Version : MetadataVersionV4 , BlockSize : bs , Size : 4 * bs , BuildId : self , BaseBuildId : legacyAncestor }
54- h , err := newDiffHeader (meta , mapping , sourceBuilds )
55- require .NoError (t , err )
56-
57- // Self is excluded: its data isn't uploaded yet.
58- _ , hasSelf := h .Builds [self ]
59- require .False (t , hasSelf )
60-
61- // Known ancestor carried forward verbatim (not clobbered by the sentinel).
62- require .Equal (t , BuildData {Size : 123 }, h .Builds [knownAncestor ])
63-
64- // Legacy ancestor gets the uncompressed sentinel, so GetBuildFrameData
65- // returns a non-nil table and the read path never proactively refreshes it.
66- bd , hasLegacy := h .Builds [legacyAncestor ]
67- require .True (t , hasLegacy )
68- require .Equal (t , BuildData {}, bd )
69- require .Equal (t , storage .UncompressedFrameTable , h .GetBuildFrameData (legacyAncestor ))
70-
71- // Empty (uuid.Nil) regions don't create entries.
72- _ , hasNil := h .Builds [uuid .Nil ]
73- require .False (t , hasNil )
74-
75- require .True (t , h .IncompletePendingUpload )
76- }
0 commit comments