From 978b795f5821fd2dc2eda8be4e31da898101ff40 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Thu, 10 Jun 2021 15:53:57 +0200 Subject: [PATCH 1/2] fix(cdn): random position --- engine/cdn/cdn_sync_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/engine/cdn/cdn_sync_test.go b/engine/cdn/cdn_sync_test.go index 34b22762f9..ce2bd9dcbe 100644 --- a/engine/cdn/cdn_sync_test.go +++ b/engine/cdn/cdn_sync_test.go @@ -139,8 +139,17 @@ func TestSyncLog(t *testing.T) { cdnUnits.Start(ctx, sdk.NewGoRoutines(ctx)) s.Units = cdnUnits - cdsStorage, ok := s.Units.Storages[0].(*cds.CDS) - require.True(t, ok) + var cdsStorage *cds.CDS + for _, sto := range s.Units.Storages { + cdsStorage = sto.(*cds.CDS) + if cdsStorage != nil { + break + } + } + + if cdsStorage == nil { + t.Fail() + } // Mock Http route gock.InterceptClient(cdsStorage.GetClient().HTTPClient()) From fd66edc415aa0965cf3990959e06879048a35993 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Fri, 11 Jun 2021 10:17:14 +0200 Subject: [PATCH 2/2] fix: unit test --- engine/cdn/storage/storageunit_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/cdn/storage/storageunit_test.go b/engine/cdn/storage/storageunit_test.go index 17fd2a0f46..c940564970 100644 --- a/engine/cdn/storage/storageunit_test.go +++ b/engine/cdn/storage/storageunit_test.go @@ -163,7 +163,7 @@ func TestDeduplicationCrossType(t *testing.T) { Type: sdk.CDNTypeItemRunResult, Status: sdk.CDNStatusItemCompleted, } - iuArtifact, err := cdnUnits.NewItemUnit(ctx, cdnUnits.Buffers[1], itemArtifact) + iuArtifact, err := cdnUnits.NewItemUnit(ctx, cdnUnits.FileBuffer(), itemArtifact) require.NoError(t, err) // Create Destination Writer @@ -188,7 +188,7 @@ func TestDeduplicationCrossType(t *testing.T) { itemArtifact.MD5 = md5S itemArtifact.Size = 0 itemArtifact.Status = sdk.CDNStatusItemCompleted - iuArtifact, err = cdnUnits.NewItemUnit(ctx, cdnUnits.Buffers[1], itemArtifact) + iuArtifact, err = cdnUnits.NewItemUnit(ctx, cdnUnits.FileBuffer(), itemArtifact) require.NoError(t, err) require.NoError(t, item.Insert(ctx, m, db, itemArtifact)) defer func() {