Project

General

Profile

Change request #676

Improve irccdctl command tests

Added by David Demelier over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
tests
Target version:
Start date:
08/07/2017
Due date:
% Done:

100%

Estimated time:
3.00 h
MFD after:
MFD revision:
Branch:
default
Bookmark:
@
Platform:

Description

Tests are very repeatitive because:

  1. they are manually added in the constructor fixture test,
  2. there is always a poll call that actually wait for the response.

Use a template based command test

Since some tests use several commands to verify the result, allows variadic templates that instanciate and add all of these commands.

template <typename... Commands>
class command_test {
public:
    template <typename Command>
    inline void add()
    {
        auto x = std::make_unique<Command>();
        x->f();
    }

    template <typename Command, typename Tail, typename... MoreTails>
    inline void add()
    {
        add<Command>();
        add<Tail, MoreTails...>();
    }

    command_test()
    {
        add<Commands...>();
    }
};

Add dedicated functions

Some of the commands will just wait for success/error responses. Add two functions:

  1. bool wait_success(const nlohmann::json& request), wait for a successful result command
  2. bool wait_error(const nlohmann::json& request, const std::string& reason), wait for an error response with the given reason

History

#1

Updated by David Demelier about 1 year ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

Also available in: Atom PDF