Skip to content

Commit

Permalink
[tests] Check that snapshots adopt given specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ricab committed Oct 23, 2023
1 parent 1ab8ddb commit 703c5dc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_base_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,39 @@ TEST_F(TestBaseSnapshot, adopts_null_parent)
auto snapshot = MockBaseSnapshot{"descendant", "descends", nullptr, specs, vm};
EXPECT_EQ(snapshot.get_parent(), nullptr);
}

TEST_F(TestBaseSnapshot, adopts_given_specs)
{
auto snapshot = MockBaseSnapshot{"snapshot", "", nullptr, specs, vm};
EXPECT_EQ(snapshot.get_num_cores(), specs.num_cores);
EXPECT_EQ(snapshot.get_mem_size(), specs.mem_size);
EXPECT_EQ(snapshot.get_disk_space(), specs.disk_space);
EXPECT_EQ(snapshot.get_state(), specs.state);
EXPECT_EQ(snapshot.get_mounts(), specs.mounts);
EXPECT_EQ(snapshot.get_metadata(), specs.metadata);
}

TEST_F(TestBaseSnapshot, adopts_custom_mounts)
{
specs.mounts["toto"] =
mp::VMMount{"src", {{123, 234}, {567, 678}}, {{19, 91}}, multipass::VMMount::MountType::Classic};
specs.mounts["tata"] =
mp::VMMount{"fountain", {{234, 123}}, {{81, 18}, {9, 10}}, multipass::VMMount::MountType::Native};

auto snapshot = MockBaseSnapshot{"snapshot", "", nullptr, specs, vm};
EXPECT_EQ(snapshot.get_mounts(), specs.mounts);
}

TEST_F(TestBaseSnapshot, adopts_custom_metadata)
{
QJsonObject json;
QJsonObject data;
data.insert("an-int", 7);
data.insert("a-str", "str");
json.insert("meta", data);
specs.metadata = json;

auto snapshot = MockBaseSnapshot{"snapshot", "", nullptr, specs, vm};
EXPECT_EQ(snapshot.get_metadata(), specs.metadata);
}
} // namespace

0 comments on commit 703c5dc

Please sign in to comment.