hdfs-rm-mock.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef LIBHDFSPP_TOOLS_HDFS_RM_MOCK
  19. #define LIBHDFSPP_TOOLS_HDFS_RM_MOCK
  20. #include <functional>
  21. #include <memory>
  22. #include <string>
  23. #include <vector>
  24. #include <gmock/gmock.h>
  25. #include "hdfs-rm.h"
  26. namespace hdfs::tools::test {
  27. /**
  28. * {@class RmMock} is an {@class Rm} whereby it mocks the
  29. * HandleHelp and HandlePath methods for testing their functionality.
  30. */
  31. class RmMock : public hdfs::tools::Rm {
  32. public:
  33. /**
  34. * {@inheritdoc}
  35. */
  36. RmMock(const int argc, char **argv) : Rm(argc, argv) {}
  37. // Abiding to the Rule of 5
  38. RmMock(const RmMock &) = delete;
  39. RmMock(RmMock &&) = delete;
  40. RmMock &operator=(const RmMock &) = delete;
  41. RmMock &operator=(RmMock &&) = delete;
  42. ~RmMock() override;
  43. /**
  44. * Defines the methods and the corresponding arguments that are expected
  45. * to be called on this instance of {@link HdfsTool} for the given test case.
  46. *
  47. * @param test_case An {@link std::function} object that points to the
  48. * function defining the test case
  49. * @param args The arguments that are passed to this test case
  50. */
  51. void SetExpectations(std::function<std::unique_ptr<RmMock>()> test_case,
  52. const std::vector<std::string> &args = {}) const;
  53. MOCK_METHOD(bool, HandleHelp, (), (const, override));
  54. MOCK_METHOD(bool, HandlePath, (const bool, const std::string &),
  55. (const, override));
  56. };
  57. } // namespace hdfs::tools::test
  58. #endif