MCPcopy Create free account
hub / github.com/Snapchat/Valdi / addAssetArtifact

Function addAssetArtifact

valdi/test/runtime/RemoteModuleManagerTests.cpp:654–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652}
653
654void addAssetArtifact(const StringBox& url,
655 const Shared<RequestManagerMock>& requestManager,
656 const Ref<DownloadableModuleManifestWrapper>& manifest,
657 double deviceDensity) {
658 auto assets1 = manifest->pb.add_assets();
659 assets1->set_device_density(deviceDensity);
660 auto assets1Artifact = assets1->mutable_artifact();
661 assets1Artifact->set_url(url.slowToString());
662
663 ValdiArchiveBuilder assetsBuilder;
664 assetsBuilder.addEntry(
665 ValdiArchiveEntry(STRING_FORMAT("density-{}", static_cast<int>(deviceDensity)), StringBox()));
666 auto assetsArtifactBytes = assetsBuilder.build();
667 auto sha256Digest = BytesUtils::sha256(assetsArtifactBytes->toBytesView());
668 // Create a string to retain the memory (otherwise the digest bytes get destructed)
669 auto sha256DigestStr = std::string(sha256Digest->toBytesView().asStringView());
670 assets1Artifact->set_sha256digest(sha256DigestStr);
671
672 requestManager->addMockedResponse(url, STRING_LITERAL("GET"), assetsArtifactBytes->toBytesView());
673}
674
675Result<Ref<RemoteModuleResources>> fetchAsset(const Shared<RequestManagerMock>& requestManager,
676 const Ref<DownloadableModuleManifestWrapper>& manifest,

Callers 1

TESTFunction · 0.85

Calls 13

add_assetsMethod · 0.80
set_device_densityMethod · 0.80
mutable_artifactMethod · 0.80
set_urlMethod · 0.80
slowToStringMethod · 0.80
addEntryMethod · 0.80
asStringViewMethod · 0.80
set_sha256digestMethod · 0.80
addMockedResponseMethod · 0.80
ValdiArchiveEntryClass · 0.50
StringBoxClass · 0.50
buildMethod · 0.45

Tested by

no test coverage detected