src/modular/bin/sessionmgr/storage/session_storage_unittest.cc
// Verifies that an on_annotations_updated callback is invoked when annotations are added/merged,
// with the correct story_name and updated annotations.
Verifies that an on_annotations_updated callback is invoked when annotations are added/merged,
with the correct story_name and updated annotations.
Verifies that an on_annotations_updated callback is invoked when annotations are added / merged with the correct story_name and updated annotations .
TEST_F(SessionStorageTest, OnAnnotationsUpdatedCallback) {
  static constexpr auto story_name = "story";
  auto storage = CreateStorage();
  storage->CreateStory(story_name, {});
  bool updated{};
  std::string updated_story_id;
  std::vector<fuchsia::modular::Annotation> updated_annotations;
  storage->add_on_annotations_updated_once(
      story_name, [&](std::string story_id, std::vector<fuchsia::modular::Annotation> annotations) {
        updated_story_id = story_id;
        updated_annotations = std::move(annotations);
        updated = true;
      });
  std::vector<fuchsia::modular::Annotation> annotations{};
  fuchsia::modular::AnnotationValue annotation_value;
  annotation_value.set_text("test_annotation_value");
  auto annotation = fuchsia::modular::Annotation{
      .key = "test_annotation_key", .value = fidl::MakeOptional(std::move(annotation_value))};
  annotations.push_back(fidl::Clone(annotation));
  storage->MergeStoryAnnotations(story_name, std::move(annotations));
  EXPECT_TRUE(updated);
  EXPECT_EQ(story_name, updated_story_id);
  ASSERT_EQ(1u, updated_annotations.size());
  EXPECT_THAT(updated_annotations.at(0), annotations::AnnotationEq(ByRef(annotation)));
}
TEST_F ( SessionStorageTest , OnAnnotationsUpdatedCallback ) { static constexpr auto story_name = " " ; auto storage = CreateStorage ( ) ; storage -> CreateStory ( story_name , { } ) ; bool updated { } ; std :: string updated_story_id ; std :: vector < fuchsia :: modular :: Annotation > updated_annotations ; storage -> add_on_annotations_updated_once ( story_name , [ & ] ( std :: string story_id , std :: vector < fuchsia :: modular :: Annotation > annotations ) { updated_story_id = story_id ; updated_annotations = std :: move ( annotations ) ; updated = true ; } ) ; std :: vector < fuchsia :: modular :: Annotation > annotations { } ; fuchsia :: modular :: AnnotationValue annotation_value ; annotation_value . set_text ( " " ) ; auto annotation = fuchsia :: modular :: Annotation { . key = " " , . value = fidl :: MakeOptional ( std :: move ( annotation_value ) ) } ; annotations . push_back ( fidl :: Clone ( annotation ) ) ; storage -> MergeStoryAnnotations ( story_name , std :: move ( annotations ) ) ; EXPECT_TRUE ( updated ) ; EXPECT_EQ ( story_name , updated_story_id ) ; ASSERT_EQ ( 1u , updated_annotations . size ( ) ) ; EXPECT_THAT ( updated_annotations . at ( 0 ) , annotations :: AnnotationEq ( ByRef ( annotation ) ) ) ; }
Verifies that an on_annotations_updated callback is invoked when annotations are added/merged,
with the correct story_name and updated annotations.
Verifies that an on_annotations_updated callback is invoked when annotations are added / merged with the correct story_name and updated annotations .
// Create a story with no annotations. /*annotations=*/ // Annotate the story.