MCPcopy Create free account
hub / github.com/aria2/aria2 / testAddMetalink

Method testAddMetalink

test/RpcMethodTest.cc:458–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456} // namespace
457
458void RpcMethodTest::testAddMetalink()
459{
460 File(e_->getOption()->get(PREF_DIR) +
461 "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
462 .remove();
463 AddMetalinkRpcMethod m;
464 {
465 // Saving upload metadata is disabled by option.
466 auto res = m.execute(createAddMetalinkReq(), e_.get());
467 CPPUNIT_ASSERT_EQUAL(0, res.code);
468 const List* resParams = downcast<List>(res.param);
469 CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size());
470 a2_gid_t gid1, gid2;
471 CPPUNIT_ASSERT_EQUAL(
472 0, GroupId::toNumericId(
473 gid1, downcast<String>(resParams->get(0))->s().c_str()));
474 CPPUNIT_ASSERT_EQUAL(
475 0, GroupId::toNumericId(
476 gid2, downcast<String>(resParams->get(1))->s().c_str()));
477 CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
478 "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
479 .exists());
480 }
481 e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
482 {
483 auto res = m.execute(createAddMetalinkReq(), e_.get());
484 CPPUNIT_ASSERT_EQUAL(0, res.code);
485 const List* resParams = downcast<List>(res.param);
486 CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size());
487 a2_gid_t gid3, gid4;
488 CPPUNIT_ASSERT_EQUAL(
489 0, GroupId::toNumericId(
490 gid3, downcast<String>(resParams->get(0))->s().c_str()));
491 CPPUNIT_ASSERT_EQUAL(
492 0, GroupId::toNumericId(
493 gid4, downcast<String>(resParams->get(1))->s().c_str()));
494 CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
495 "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
496 .exists());
497
498 auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
499 CPPUNIT_ASSERT(tar);
500 CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR) +
501 "/aria2-5.0.0.tar.bz2",
502 tar->getFirstFilePath());
503 auto deb = findReservedGroup(e_->getRequestGroupMan().get(), gid4);
504 CPPUNIT_ASSERT(deb);
505 CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR) + "/aria2-5.0.0.deb",
506 deb->getFirstFilePath());
507 }
508 {
509 auto req = createAddMetalinkReq();
510 // with options
511 std::string dir = A2_TEST_OUT_DIR "/aria2_RpcMethodTest_testAddMetalink";
512 File(dir).mkdirs();
513 auto opt = Dict::g();
514 opt->put(PREF_DIR->k, dir);
515 File(dir + "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").remove();

Callers

nothing calls this directly

Calls 14

FileClass · 0.85
createAddMetalinkReqFunction · 0.85
findReservedGroupFunction · 0.85
getOptionMethod · 0.80
getRequestGroupManMethod · 0.80
getFirstFilePathMethod · 0.80
mkdirsMethod · 0.80
removeMethod · 0.45
getMethod · 0.45
executeMethod · 0.45
sizeMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected