feat: add Test for WifiConnect API
This commit is contained in:
parent
9811022b76
commit
5784e38fbb
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"__bit_reference": "cpp",
|
||||||
|
"__hash_table": "cpp",
|
||||||
|
"__split_buffer": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp"
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,10 @@
|
|||||||
; Add additionnal environments in this file
|
; Add additionnal environments in this file
|
||||||
|
; Debug environemnt
|
||||||
|
[env:test]
|
||||||
|
test_build_src = true
|
||||||
|
build_type = debug
|
||||||
|
build_flags = ${env.build_flags}
|
||||||
|
-D TESTING
|
||||||
|
|
||||||
; Default production environment
|
; Default production environment
|
||||||
[env:prod]
|
[env:prod]
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
; Add secrets token/logins/etc `secrets.ini`
|
|
||||||
; Add the sames values as blank in `secrets.ini.example
|
|
||||||
; To be able to reproduce it
|
|
||||||
|
|
||||||
[secrets]
|
|
||||||
build_flags =
|
|
||||||
|
|
||||||
-D WIFI_SSID=\"...\"
|
|
||||||
-D WIFI_PASSWORD=\"...\"4
|
|
||||||
|
|
||||||
-D USER_NAME=\"...\"
|
|
||||||
-D USER_PASSWORD=\"...\"
|
|
@ -1,3 +1,5 @@
|
|||||||
|
#ifndef TESTING
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Program.h"
|
#include "Program.h"
|
||||||
|
|
||||||
@ -10,3 +12,5 @@ void setup() {
|
|||||||
void loop() {
|
void loop() {
|
||||||
program->loop();
|
program->loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
20
IOT/test/main.cpp
Normal file
20
IOT/test/main.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
#include <unity.h>
|
||||||
|
#include "test.h"
|
||||||
|
void setup() {
|
||||||
|
delay(2000);
|
||||||
|
// start unit tests engine
|
||||||
|
UNITY_BEGIN();
|
||||||
|
Serial.begin(115200);
|
||||||
|
RUN_TEST(TestWifiBeginConnected);
|
||||||
|
RUN_TEST(TestWifiBeginNotConnected);
|
||||||
|
|
||||||
|
|
||||||
|
UNITY_END();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
}
|
7
IOT/test/test.h
Normal file
7
IOT/test/test.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef TEST_H
|
||||||
|
#define TEST_H
|
||||||
|
|
||||||
|
void TestWifiBeginConnected();
|
||||||
|
void TestWifiBeginNotConnected();
|
||||||
|
|
||||||
|
#endif
|
19
IOT/test/test_api.cpp
Normal file
19
IOT/test/test_api.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "test.h"
|
||||||
|
#include <unity.h>
|
||||||
|
#include "API.h"
|
||||||
|
|
||||||
|
void TestWifiBeginConnected() {
|
||||||
|
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||||
|
|
||||||
|
Serial1.begin(MONITOR_SPEED);
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(true, api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1), "Wifi not connected");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestWifiBeginNotConnected() {
|
||||||
|
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||||
|
|
||||||
|
Serial2.begin(MONITOR_SPEED);
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(false, api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial2), "Wifi connected");
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user