vendredi 27 décembre 2019

MOCK_METHOD() - mocking a function that listens to a HTTP post

I have the following test MyClassTestTest.when_fileDownloadedFromServer_then_checksumIsCorrect. The function downloadFile(), does a http GET command to a specific URL, downloads the file and calculates the md5sum of the file.

TEST_F(MyClassTestTest, when_fileDownloadedFromServer_then_checksumIsCorrect) {
    EXPECT_EQ(m_Test->getLinuxAdapterValues()->downloadSuccess, false);
    m_Test->downloadFile();
    EXPECT_EQ(m_Test->getLinuxAdapterValues()->downloadSuccess, true);
    EXPECT_EQ(m_Test->getLinuxAdapterValues()->md5sum, "dbfa46c88e9ce5b3f33e4b6a5502c9a2");
}

Instead of having a python Flask API, running http server, I want to mock function that will wait for a http GET. Can I do that? Is it possible using google mock.

Aucun commentaire:

Enregistrer un commentaire