blob: a618720eaae67931bc30ad37674302fd02bb7134 [file] [log] [blame]
James Feist139cb572018-09-10 15:26:18 -07001#include <HwmonTempSensor.hpp>
2#include <dbus/connection.hpp>
3#include <nlohmann/json.hpp>
4#include <fstream>
5#include "gtest/gtest.h"
6
7TEST(HwmonTempSensor, TestTMP75)
8{
9 boost::asio::io_service io;
10 auto system_bus =
11 std::make_shared<dbus::connection>(io, dbus::bus::session);
12 dbus::DbusObjectServer object_server(system_bus);
13
14 std::vector<thresholds::Threshold> sensor_thresholds;
15 auto t = thresholds::Threshold(thresholds::Level::CRITICAL,
16 thresholds::Direction::LOW, 80);
17 sensor_thresholds.emplace_back(t);
18
19 std::ofstream test_file("test0.txt");
20 test_file << "28\n";
21 test_file.close();
22 auto filename = std::string("test0.txt");
23 auto tempsensname = std::string("test sensor");
24 HwmonTempSensor test(filename, object_server, io, tempsensname,
25 std::move(sensor_thresholds));
26
27 std::remove("test0.txt");
28}
29
30TEST(HwmonTempSensor, TestTMP421)
31{
32 boost::asio::io_service io;
33 auto system_bus =
34 std::make_shared<dbus::connection>(io, dbus::bus::session);
35 dbus::DbusObjectServer object_server(system_bus);
36
37 std::vector<thresholds::Threshold> sensor_thresholds;
38 auto t = thresholds::Threshold(thresholds::Level::WARNING,
39 thresholds::Direction::HIGH, 80);
40 sensor_thresholds.emplace_back(t);
41
42 std::ofstream test_file("test1.txt");
43 test_file << "28\n";
44 test_file.close();
45 auto filename = std::string("test1.txt");
46 auto tempsensname = std::string("test sensor");
47 HwmonTempSensor test(filename, object_server, io, tempsensname,
48 std::move(sensor_thresholds));
49
50 std::remove("test1.txt");
51}