Mock siad changes
This commit is contained in:
@@ -155,8 +155,9 @@ void CMockSiad::Start(const SiadTestType& testType)
|
||||
|
||||
struct sockaddr_in sockAddr = { 0 };
|
||||
sockAddr.sin_family = AF_INET;
|
||||
sockAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
sockAddr.sin_port = htons(19980);
|
||||
sockAddr.sin_addr.s_addr = inet_addr(CW2A(_hostConfig.HostName.c_str()));
|
||||
sockAddr.sin_port = htons(_hostConfig.HostPort);
|
||||
|
||||
bool listening = ((listenSocket != INVALID_SOCKET) && (::bind(listenSocket, reinterpret_cast<const struct sockaddr *>(&sockAddr), sizeof(sockAddr)) != SOCKET_ERROR)) && (::listen(listenSocket, 1) != SOCKET_ERROR);
|
||||
while (listening && ((active = (::WaitForSingleObject(_stopEvent, 1) == WAIT_TIMEOUT))))
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define TEST_SERVER_HOST L"localhost"
|
||||
#define TEST_SERVER_HOST L"127.0.0.1"
|
||||
#define TEST_SERVER_PORT 11980
|
||||
#define TEST_SERVER_AND_PORT TEST_SERVER_HOST, TEST_SERVER_PORT
|
||||
#define TEST_SERVER_VERSION L"1.1.0"
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "UploadManager.h"
|
||||
#include "MockSiad.h"
|
||||
#include "SiaDriveConfig.h"
|
||||
#include "UnitTestConfig.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
using namespace Sia::Api;
|
||||
@@ -13,12 +14,15 @@ namespace UnitTests
|
||||
TEST_CLASS(UnitTests)
|
||||
{
|
||||
private:
|
||||
const SiaHostConfig hostConfig = { L"localhost", 19980, L"1.1.0" };
|
||||
const SiaHostConfig hostConfig = { TEST_SERVER_AND_PORT, TEST_SERVER_VERSION };
|
||||
static std::unique_ptr<CMockSiad> siad;
|
||||
|
||||
public:
|
||||
TEST_METHOD_INITIALIZE(Initialize)
|
||||
{
|
||||
CSiaDriveConfig config;
|
||||
::DeleteFileA(config.GetRenter_UploadDbFilePath().c_str());
|
||||
|
||||
siad.reset(new CMockSiad(hostConfig));
|
||||
}
|
||||
|
||||
@@ -40,6 +44,7 @@ namespace UnitTests
|
||||
CSiaDriveConfig driveConfig;
|
||||
CSiaCurl siaCurl(hostConfig);
|
||||
String version = siaCurl.GetServerVersion();
|
||||
Assert::AreEqual(version.c_str(), TEST_SERVER_VERSION); // Connectivity test
|
||||
|
||||
CUploadManager uploadManager(siaCurl, &driveConfig);
|
||||
uploadManager.AddOrUpdate(L"/test1/test.txt", L"./test1/test.txt");
|
||||
|
Reference in New Issue
Block a user