Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mocks to their own interface #4645

Merged
merged 3 commits into from
May 20, 2023
Merged

Conversation

pajlada
Copy link
Member

@pajlada pajlada commented May 20, 2023

Description

Code mostly taken from https://github.com/Chatterino/chatterino2/pull/4644/files

This allows us to share mocks between multiple projects (i.e. tests & benchmarks)

@pajlada
Copy link
Member Author

pajlada commented May 20, 2023

LGTM
image

@pajlada pajlada enabled auto-merge (squash) May 20, 2023 10:13
@pajlada pajlada merged commit e1a6c24 into master May 20, 2023
@pajlada pajlada deleted the chore/move-mocks-to-its-own-library branch May 20, 2023 10:54
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 53. Check the log or trigger a new build to see more.

@@ -1,11 +1,12 @@
#include "Application.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'Application.hpp' file not found [clang-diagnostic-error]

#include "Application.hpp"
         ^

@@ -45,65 +46,17 @@
}
};

class MockApplication : IApplication
class MockApplication : mock::EmptyApplication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: accounts, highlights [cppcoreguidelines-pro-type-member-init]

benchmarks/src/Highlights.cpp:60:

-     AccountController accounts;
-     HighlightController highlights;
+     AccountController accounts{};
+     HighlightController highlights{};

@@ -0,0 +1,81 @@
#pragma once

#include "Application.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'Application.hpp' file not found [clang-diagnostic-error]

#include "Application.hpp"
         ^


#include <vector>

namespace chatterino::mock {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp]

namespace chatterino::mock {
          ^
Additional context

/usr/include/c++/11/bits/unique_ptr.h:44: 'std' namespace opened here

namespace std _GLIBCXX_VISIBILITY(default)
          ^

public:
virtual ~Helix() = default;

MOCK_METHOD(void, fetchUsers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, fetchUsers,
mockMethod(void, fetchUsers,

HelixFailureCallback failureCallback),
(override));

MOCK_METHOD(void, unblockUser,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, unblockUser,
mockMethod(void, unblockUser,

HelixFailureCallback failureCallback),
(override));

MOCK_METHOD(void, updateChannel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, updateChannel,
mockMethod(void, updateChannel,

HelixFailureCallback failureCallback),
(override));

MOCK_METHOD(void, manageAutoModMessages,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, manageAutoModMessages,
mockMethod(void, manageAutoModMessages,

std::function<void(HelixAutoModMessageError)> failureCallback),
(override));

MOCK_METHOD(void, getCheermotes,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, getCheermotes,
mockMethod(void, getCheermotes,

HelixFailureCallback failureCallback),
(override));

MOCK_METHOD(void, getEmoteSetData,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, getEmoteSetData,
mockMethod(void, getEmoteSetData,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant