proxygen
RequestContextTest Class Reference
Inheritance diagram for RequestContextTest:
testing::Test

Protected Member Functions

void SetUp () override
 
RequestContextgetContext ()
 
void setData (int data=0, std::string key="test")
 
bool hasData (std::string key="test")
 
const TestDatagetData (std::string key="test")
 
void clearData (std::string key="test")
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 

Detailed Description

Definition at line 49 of file RequestContextTest.cpp.

Member Function Documentation

void RequestContextTest::clearData ( std::string  key = "test")
inlineprotected

Definition at line 90 of file RequestContextTest.cpp.

90  {
92  }
void clearContextData(const RequestToken &val)
Definition: Request.cpp:176
RequestContext & getContext()
RequestContext& RequestContextTest::getContext ( )
inlineprotected

Definition at line 70 of file RequestContextTest.cpp.

References EXPECT_TRUE, and folly::RequestContext::get().

70  {
71  auto* ctx = RequestContext::get();
72  EXPECT_TRUE(ctx != nullptr);
73  return *ctx;
74  }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
Definition: submit.h:391
const TestData& RequestContextTest::getData ( std::string  key = "test")
inlineprotected

Definition at line 84 of file RequestContextTest.cpp.

References EXPECT_TRUE, and ptr.

84  {
85  auto* ptr = dynamic_cast<TestData*>(getContext().getContextData(key));
86  EXPECT_TRUE(ptr != nullptr);
87  return *ptr;
88  }
void * ptr
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
RequestContext & getContext()
RequestData * getContextData(const RequestToken &val)
Definition: Request.cpp:151
bool RequestContextTest::hasData ( std::string  key = "test")
inlineprotected

Definition at line 80 of file RequestContextTest.cpp.

80  {
81  return getContext().hasContextData(key);
82  }
RequestContext & getContext()
bool hasContextData(const RequestToken &val) const
Definition: Request.cpp:147
void RequestContextTest::setData ( int  data = 0,
std::string  key = "test" 
)
inlineprotected

Definition at line 76 of file RequestContextTest.cpp.

References folly::data().

76  {
77  getContext().setContextData(key, std::make_unique<TestData>(data));
78  }
void setContextData(const RequestToken &val, std::unique_ptr< RequestData > data)
Definition: Request.cpp:129
RequestContext & getContext()
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
void RequestContextTest::SetUp ( )
inlineoverrideprotectedvirtual

Reimplemented from testing::Test.

Definition at line 51 of file RequestContextTest.cpp.

References folly::RequestContext::setContext().

51  {
52  // Make sure each test starts out using the default context, and not some
53  // other context left over by a previous test.
54  RequestContext::setContext(nullptr);
55 
56  // Make sure no data is set for the "test" key when we start. There could
57  // be left over data in the default context from a previous test. If we
58  // don't clear it out future calls to setContextData() won't actually work,
59  // and will reset the data to null instead of properly setting the new
60  // desired data.
61  //
62  // (All of the tests generally want the behavior of overwriteContextData()
63  // rather than setContextData(), but that method is private.)
64  //
65  // We ideally want to clear out data for any keys that may be set, not just
66  // the "test" key, but there also isn't a RequestContext API to do this.
67  clearData();
68  }
void clearData(std::string key="test")

The documentation for this class was generated from the following file: