MCPcopy Create free account
hub / github.com/apache/mesos / TEST

Function TEST

src/tests/common_validation_tests.cpp:27–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace tests {
26
27TEST(CommonValidationTest, Volume)
28{
29 // One of the 'host_path', 'image' or 'source' must be set.
30 {
31 Volume volume;
32 volume.set_container_path("container_path");
33 volume.set_mode(Volume::RW);
34
35 EXPECT_SOME_EQ(
36 Error("Only one of them should be set: "
37 "'host_path', 'image' and 'source'"),
38 common::validation::validateVolume(volume));
39
40 volume.set_host_path("host_path");
41 volume.mutable_image();
42
43 EXPECT_SOME_EQ(
44 Error("Only one of them should be set: "
45 "'host_path', 'image' and 'source'"),
46 common::validation::validateVolume(volume));
47 }
48
49 // Source 'type' is compatible with the corresponding fields.
50 {
51 Volume volume;
52 volume.set_container_path("container_path");
53 volume.set_mode(Volume::RW);
54
55 Volume::Source* source = volume.mutable_source();
56 source->set_type(Volume::Source::DOCKER_VOLUME);
57
58 EXPECT_SOME_EQ(
59 Error("'source.docker_volume' is not set for "
60 "DOCKER_VOLUME volume"),
61 common::validation::validateVolume(volume));
62
63 source->set_type(Volume::Source::HOST_PATH);
64
65 EXPECT_SOME_EQ(
66 Error("'source.host_path' is not set for "
67 "HOST_PATH volume"),
68 common::validation::validateVolume(volume));
69
70 source->set_type(Volume::Source::SANDBOX_PATH);
71
72 EXPECT_SOME_EQ(
73 Error("'source.sandbox_path' is not set for "
74 "SANDBOX_PATH volume"),
75 common::validation::validateVolume(volume));
76
77 source->set_type(Volume::Source::SECRET);
78
79 EXPECT_SOME_EQ(
80 Error("'source.secret' is not set for "
81 "SECRET volume"),
82 common::validation::validateVolume(volume));
83 }
84}

Callers

nothing calls this directly

Calls 4

validateVolumeFunction · 0.85
insertMethod · 0.80
ErrorFunction · 0.50
validateOfferFiltersFunction · 0.50

Tested by

no test coverage detected