sapling/eden/fs/testharness/TestServer.h
Adam Simpkins 67cd4bbf45 add a TestServer class
Summary:
Add a helper class for creating an EdenServer in a unit test.

Most of our existing unit tests only create EdenMount objects, without a full
EdenServer.  This new class will make it easier to write tests for
functionality that does require a full EdenServer object.

Reviewed By: chadaustin

Differential Revision: D15492166

fbshipit-source-id: f8b1ce3b78a1160a5d55d305e6bf4b5305cca509
2019-05-28 21:39:39 -07:00

48 lines
1002 B
C++

/*
* Copyright (c) 2019-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <memory>
#include <folly/experimental/TestUtil.h>
#include "eden/fs/utils/PathFuncs.h"
namespace facebook {
namespace eden {
class EdenServer;
/**
* TestServer helps create an EdenServer object for use in unit tests.
*
* It contains a temporary directory object, and an EdenServer.
*/
class TestServer {
public:
TestServer();
~TestServer();
AbsolutePath getTmpDir() const;
EdenServer& getServer() {
return *server_;
}
private:
static std::unique_ptr<EdenServer> createServer(AbsolutePathPiece tmpDir);
folly::test::TemporaryDirectory tmpDir_;
std::unique_ptr<EdenServer> server_;
};
} // namespace eden
} // namespace facebook