Skip to content

Commit

Permalink
Fix ResultType tests
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Dec 29, 2021
1 parent 9660181 commit 8fe711d
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions src/FuelClient_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,13 @@ TEST_F(FuelClientTest, DownloadModel)
std::string cachedPath;
Result res1 = client.CachedModel(url, cachedPath);
EXPECT_FALSE(res1);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1);
EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type());

// Download
std::string path;
Result res2 = client.DownloadModel(url, path);
EXPECT_TRUE(res2);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res2);
EXPECT_EQ(ResultType::FETCH, res2.Type());

// Check it was downloaded to `2`
auto modelPath = common::joinPaths(common::cwd(), "test_cache",
Expand All @@ -447,7 +447,7 @@ TEST_F(FuelClientTest, DownloadModel)
// Check it is cached
Result res3 = client.CachedModel(url, cachedPath);
EXPECT_TRUE(res3);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res3.Type());
EXPECT_EQ(common::joinPaths(modelPath, "2"), cachedPath);
}

Expand All @@ -461,13 +461,13 @@ TEST_F(FuelClientTest, DownloadModel)
std::string cachedPath;
Result res1 = client.CachedModel(url, cachedPath);
EXPECT_FALSE(res1);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1);
EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type());

// Download
std::string path;
Result res2 = client.DownloadModel(url, path);
EXPECT_TRUE(res2);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res2);
EXPECT_EQ(ResultType::FETCH, res2.Type());

// Check it was downloaded to `2`
auto modelPath = common::joinPaths(common::cwd(), "test_cache",
Expand All @@ -485,7 +485,7 @@ TEST_F(FuelClientTest, DownloadModel)
// Check it is cached
Result res3 = client.CachedModel(url, cachedPath);
EXPECT_TRUE(res3);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res3.Type());
EXPECT_EQ(common::joinPaths(modelPath, "2"), cachedPath);

// Check that URIs have been updated.
Expand Down Expand Up @@ -516,28 +516,28 @@ TEST_F(FuelClientTest, DownloadModel)
std::string cachedPath;
Result res1 = client.CachedModel(url, cachedPath);
EXPECT_FALSE(res1);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1);
EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type());

// Check the dependency is not cached
Result res2 = client.CachedModel(depUrl, cachedPath);
EXPECT_FALSE(res2);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res2);
EXPECT_EQ(ResultType::FETCH_ERROR, res2.Type());

// Download
std::string path;
Result res3 = client.DownloadModel(url, path);
EXPECT_TRUE(res3);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3);
EXPECT_EQ(ResultType::FETCH, res3.Type());

// Check it is cached
Result res4 = client.CachedModel(url, cachedPath);
EXPECT_TRUE(res4);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res4);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res4.Type());

// Check the dependency is cached
Result res5 = client.CachedModel(depUrl, cachedPath);
EXPECT_TRUE(res5);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res5);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res5.Type());
}

// Download model with a dependency specified within its `model.config`
Expand All @@ -551,28 +551,28 @@ TEST_F(FuelClientTest, DownloadModel)
std::string cachedPath;
Result res1 = client.CachedModel(url, cachedPath);
EXPECT_FALSE(res1);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1);
EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type());

// Check the dependency is not cached
Result res2 = client.CachedModel(depUrl, cachedPath);
EXPECT_FALSE(res2);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res2);
EXPECT_EQ(ResultType::FETCH_ERROR, res2.Type());

// Download
std::string path;
Result res3 = client.DownloadModel(url, path);
EXPECT_TRUE(res3);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3);
EXPECT_EQ(ResultType::FETCH, res3.Type());

// Check it is cached
Result res4 = client.CachedModel(url, cachedPath);
EXPECT_TRUE(res4);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res4);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res4.Type());

// Check the dependency is cached
Result res5 = client.CachedModel(depUrl, cachedPath);
EXPECT_TRUE(res5);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res5);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res5.Type());
}

// Try using nonexistent URL
Expand All @@ -583,7 +583,7 @@ TEST_F(FuelClientTest, DownloadModel)
std::string path;
Result result = client.DownloadModel(common::URI(url), path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Try using bad URL
Expand All @@ -592,7 +592,7 @@ TEST_F(FuelClientTest, DownloadModel)
std::string path;
Result result = client.DownloadModel(common::URI(url), path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}
}

Expand All @@ -619,7 +619,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModel(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007",
"alice", "models", "My Model", "3"), path);
}
Expand All @@ -630,7 +630,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModel(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007",
"alice", "models", "My Model", "3"), path);
}
Expand All @@ -641,7 +641,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModel(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007",
"alice", "models", "My Model", "2"), path);
}
Expand All @@ -653,7 +653,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModelFile(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007",
"alice", "models", "My Model", "3", "model.sdf"), path);
}
Expand All @@ -665,7 +665,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModelFile(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007",
"alice", "models", "My Model", "2", "meshes", "model.dae"), path);
}
Expand All @@ -676,7 +676,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModel(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Non-cached model (when looking for file)
Expand All @@ -685,7 +685,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModelFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Non-cached model file
Expand All @@ -696,7 +696,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModelFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Model root URL to model file
Expand All @@ -705,7 +705,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModelFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Bad model URL
Expand All @@ -714,7 +714,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModel(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Bad model file URL
Expand All @@ -723,7 +723,7 @@ TEST_F(FuelClientTest, CachedModel)
std::string path;
auto result = client.CachedModelFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}
}

Expand Down Expand Up @@ -1019,13 +1019,13 @@ TEST_F(FuelClientTest, DownloadWorld)
std::string cachedPath;
auto res1 = client.CachedWorld(url, cachedPath);
EXPECT_FALSE(res1);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1);
EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type());

// Download
std::string path;
auto res2 = client.DownloadWorld(url, path);
EXPECT_TRUE(res2);
EXPECT_EQ(Result(ResultType::FETCH), res2);
EXPECT_EQ(ResultType::FETCH, res2.Type());

// Check it was downloaded to `1`
auto worldPath = common::joinPaths(common::cwd(), "test_cache",
Expand All @@ -1041,7 +1041,7 @@ TEST_F(FuelClientTest, DownloadWorld)
// Check it is cached
auto res3 = client.CachedWorld(url, cachedPath);
EXPECT_TRUE(res3);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res3.Type());
EXPECT_EQ(common::joinPaths(worldPath, "2"), cachedPath);
}

Expand All @@ -1052,7 +1052,7 @@ TEST_F(FuelClientTest, DownloadWorld)
std::string path;
auto result = client.DownloadWorld(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Try using bad URL
Expand All @@ -1061,7 +1061,7 @@ TEST_F(FuelClientTest, DownloadWorld)
std::string path;
auto result = client.DownloadWorld(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}
}

Expand All @@ -1088,7 +1088,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorld(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache",
"localhost:8007", "banana", "worlds", "My World", "3"), path);
}
Expand All @@ -1099,7 +1099,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorld(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache",
"localhost:8007", "banana", "worlds", "My World", "3"), path);
}
Expand All @@ -1110,7 +1110,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorld(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache",
"localhost:8007", "banana", "worlds", "My World", "2"), path);
}
Expand All @@ -1122,7 +1122,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorldFile(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache",
"localhost:8007", "banana", "worlds", "My World", "3",
"strawberry.world"), path);
Expand All @@ -1135,7 +1135,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorldFile(url, path);
EXPECT_TRUE(result);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result);
EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type());
EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache",
"localhost:8007", "banana", "worlds", "My World", "2",
"strawberry.world"), path);
Expand All @@ -1147,7 +1147,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorld(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Non-cached world (when looking for file)
Expand All @@ -1157,7 +1157,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorldFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Non-cached world file
Expand All @@ -1167,7 +1167,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorldFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// World root URL to world file
Expand All @@ -1176,7 +1176,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorldFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Bad world URL
Expand All @@ -1185,7 +1185,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorld(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}

// Bad world file URL
Expand All @@ -1194,7 +1194,7 @@ TEST_F(FuelClientTest, CachedWorld)
std::string path;
auto result = client.CachedWorldFile(url, path);
EXPECT_FALSE(result);
EXPECT_EQ(Result(ResultType::FETCH_ERROR), result);
EXPECT_EQ(ResultType::FETCH_ERROR, result.Type());
}
}

Expand Down

0 comments on commit 8fe711d

Please sign in to comment.