forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coverage: improve coverage for compressor filter (envoyproxy#11438)
coverage: improve coverage for compressor filter Risk Level: Low Testing: generated coverage report locally Signed-off-by: Dmitry Rozhkov <[email protected]>
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "extensions/filters/http/compressor/config.h" | ||
|
||
#include "test/mocks/server/mocks.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace Envoy { | ||
namespace Extensions { | ||
namespace HttpFilters { | ||
namespace Compressor { | ||
namespace { | ||
|
||
using testing::NiceMock; | ||
|
||
TEST(CompressorFilterFactoryTests, MissingCompressorLibraryConfig) { | ||
const envoy::extensions::filters::http::compressor::v3::Compressor proto_config; | ||
CompressorFilterFactory factory; | ||
NiceMock<Server::Configuration::MockFactoryContext> context; | ||
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context), | ||
EnvoyException, | ||
"Compressor filter doesn't have compressor_library defined"); | ||
} | ||
|
||
TEST(CompressorFilterFactoryTests, UnregisteredCompressorLibraryConfig) { | ||
const std::string yaml_string = R"EOF( | ||
compressor_library: | ||
name: fake_compressor | ||
typed_config: | ||
"@type": type.googleapis.com/test.mock_compressor_library.Unregistered | ||
)EOF"; | ||
|
||
envoy::extensions::filters::http::compressor::v3::Compressor proto_config; | ||
TestUtility::loadFromYaml(yaml_string, proto_config); | ||
CompressorFilterFactory factory; | ||
NiceMock<Server::Configuration::MockFactoryContext> context; | ||
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context), | ||
EnvoyException, | ||
"Didn't find a registered implementation for type: " | ||
"'test.mock_compressor_library.Unregistered'"); | ||
} | ||
|
||
} // namespace | ||
} // namespace Compressor | ||
} // namespace HttpFilters | ||
} // namespace Extensions | ||
} // namespace Envoy |
6 changes: 6 additions & 0 deletions
6
test/extensions/filters/http/compressor/mock_compressor_library.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
syntax = "proto3"; | ||
|
||
package test.mock_compressor_library; | ||
|
||
message Unregistered { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters