aboutsummaryrefslogtreecommitdiff
path: root/include/weave/provider/test/mock_config_store.h
blob: cdae693484dc7f60f21cb335fb79fb4c5a6dc6a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2015 The Weave Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_CONFIG_STORE_H_
#define LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_CONFIG_STORE_H_

#include <map>
#include <string>
#include <vector>

#include <gmock/gmock.h>
#include <weave/provider/config_store.h>

namespace weave {
namespace provider {
namespace test {

class MockConfigStore : public ConfigStore {
 public:
  MockConfigStore() {
    using testing::_;
    using testing::Return;

    EXPECT_CALL(*this, LoadDefaults(_))
        .WillRepeatedly(testing::Invoke([](Settings* settings) {
          settings->firmware_version = "TEST_FIRMWARE";
          settings->oem_name = "TEST_OEM";
          settings->model_name = "TEST_MODEL";
          settings->model_id = "ABCDE";
          settings->name = "TEST_NAME";
          settings->client_id = "TEST_CLIENT_ID";
          settings->client_secret = "TEST_CLIENT_SECRET";
          settings->api_key = "TEST_API_KEY";
          return true;
        }));
    EXPECT_CALL(*this, LoadSettings())
        .WillRepeatedly(Return(R"({
          "version": 1,
          "device_id": "TEST_DEVICE_ID"
        })"));
    EXPECT_CALL(*this, LoadSettings("config")).WillRepeatedly(Return(""));
    EXPECT_CALL(*this, SaveSettings("config", _)).WillRepeatedly(Return());
  }
  MOCK_METHOD1(LoadDefaults, bool(Settings*));
  MOCK_METHOD1(LoadSettings, std::string(const std::string&));
  MOCK_METHOD2(SaveSettings, void(const std::string&, const std::string&));
  MOCK_METHOD0(LoadSettings, std::string());
};

}  // namespace test
}  // namespace provider
}  // namespace weave

#endif  // LIBWEAVE_INCLUDE_WEAVE_PROVIDER_TEST_MOCK_CONFIG_STORE_H_