Merge branch 'feat/ota-branch-switch' into merge/ota-branch-into-observer-firmware-dev

# Conflicts:
#	.github/workflows/build-observer-firmwares.yml
#	examples/simple_repeater/MyMesh.cpp
#	examples/simple_room_server/MyMesh.cpp
#	src/helpers/ESP32Board.cpp
#	src/helpers/ESP32Board.h
#	test/test_config_serializer/test_config_serializer.cpp
This commit is contained in:
agessaman committed 2026-10-03 15:24:33 -07:00
commit ee88192acb
17 files changed
+383 -48

No files matched your search

@@ -467,6 +467,35 @@ TEST(DynamicConfigSerializer, LoadCustom_Basic) {
EXPECT_TRUE(g2);
EXPECT_STREQ("Scott", tmp);
}
TEST(NodePrefs, OtaChannelDefaultsToNative) {
NodePrefs prefs;
EXPECT_EQ(0, prefs.ota_channel); // 0 == native
}
TEST(NodePrefs, OtaChannelRoundTrip) {
NodePrefs saved;
saved.ota_channel = 2; // dev
MockPrintStream output;
ASSERT_TRUE(saved.saveSerial(output));
std::string serialised(reinterpret_cast<const char*>(output.getBytes()), output.getLength());
EXPECT_NE(std::string::npos, serialised.find("ota_ch:2"));
MockInputStream input(serialised.c_str());
NodePrefs loaded;
loaded.ota_channel = 1; // start different
ASSERT_TRUE(loaded.loadSerial(input)) << serialised;
EXPECT_EQ(2, loaded.ota_channel);
}
TEST(NodePrefs, OtaChannelMissingKeyKeepsDefault) {
// A /prefs.json written before this field existed has no ota_ch key.
MockInputStream input("{name:\"n\"}");
NodePrefs loaded; // ota_channel default 0 (native)
ASSERT_TRUE(loaded.loadSerial(input));
EXPECT_EQ(0, loaded.ota_channel);
}
// ── main ───────────────────────────────────────────────────────
@@ -0,0 +1,46 @@
#include <gtest/gtest.h>
#include "helpers/OtaChannel.h"
// The three base URLs are provided as -D macros by the test env (see platformio.ini).
TEST(OtaChannel, ResolvesNativeToBaseMacro) {
EXPECT_STREQ(ota_resolve_base(OTA_CH_NATIVE), "https://stable.example/mqtt/v");
}
TEST(OtaChannel, ResolvesStable) {
EXPECT_STREQ(ota_resolve_base(OTA_CH_STABLE), "https://stable.example/mqtt/v");
}
TEST(OtaChannel, ResolvesDev) {
EXPECT_STREQ(ota_resolve_base(OTA_CH_DEV), "https://dev.example/mqtt/dev/v");
}
TEST(OtaChannel, BasesAreStoredBehindCiTags) {
EXPECT_STREQ(ota_tagged_native, "ota-base-native:https://stable.example/mqtt/v");
EXPECT_STREQ(ota_tagged_stable, "ota-base-stable:https://stable.example/mqtt/v");
EXPECT_STREQ(ota_tagged_dev, "ota-base-dev:https://dev.example/mqtt/dev/v");
}
TEST(OtaChannel, ParseKnownKeywords) {
uint8_t ch = 99;
EXPECT_TRUE(ota_parse_channel("prod", &ch)); EXPECT_EQ(ch, OTA_CH_STABLE);
EXPECT_TRUE(ota_parse_channel("stable", &ch)); EXPECT_EQ(ch, OTA_CH_STABLE);
EXPECT_TRUE(ota_parse_channel("beta", &ch)); EXPECT_EQ(ch, OTA_CH_DEV);
EXPECT_TRUE(ota_parse_channel("default", &ch)); EXPECT_EQ(ch, OTA_CH_NATIVE);
EXPECT_TRUE(ota_parse_channel("dev", &ch)); EXPECT_EQ(ch, OTA_CH_DEV);
}
TEST(OtaChannel, ParseRejectsUnknownAndLeavesOutputUntouched) {
uint8_t ch = 7;
EXPECT_FALSE(ota_parse_channel("production", &ch));
EXPECT_FALSE(ota_parse_channel("Beta", &ch));
EXPECT_FALSE(ota_parse_channel("", &ch));
EXPECT_EQ(ch, 7);
}
TEST(OtaChannel, NameLabels) {
EXPECT_STREQ(ota_channel_name(OTA_CH_NATIVE), "default");
EXPECT_STREQ(ota_channel_name(OTA_CH_STABLE), "prod");
EXPECT_STREQ(ota_channel_name(OTA_CH_DEV), "beta");
}
TEST(OtaChannel, NativeChannelNameMatchesBase) {
EXPECT_STREQ(ota_native_channel_name(), "prod");
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}