feat: add snapshot tests for eventsub messages (#5965)
This commit is contained in:
@@ -175,6 +175,29 @@ QStringList Snapshot::discover(const QString &category)
|
||||
return files;
|
||||
}
|
||||
|
||||
QStringList Snapshot::discoverNested(const QString &category)
|
||||
{
|
||||
auto directories =
|
||||
baseDir(category).entryList(QDir::NoDotAndDotDot | QDir::Dirs);
|
||||
QStringList all;
|
||||
for (const auto &dir : directories)
|
||||
{
|
||||
auto d = baseDir(category);
|
||||
d.cd(dir);
|
||||
auto files = d.entryList(QDir::NoDotAndDotDot | QDir::Files);
|
||||
for (const auto &file : files)
|
||||
{
|
||||
QStringView view(file);
|
||||
if (view.endsWith(u".json"))
|
||||
{
|
||||
view = view.sliced(0, view.size() - 5);
|
||||
}
|
||||
all.append(dir % u'/' % view);
|
||||
}
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
bool Snapshot::run(const QJsonValue &got, bool updateSnapshots) const
|
||||
{
|
||||
if (updateSnapshots)
|
||||
|
||||
@@ -70,6 +70,9 @@ public:
|
||||
/// Finds all tests in @a category
|
||||
static QStringList discover(const QString &category);
|
||||
|
||||
/// Finds all 1-level nested tests in @a category (category/foo/bar)
|
||||
static QStringList discoverNested(const QString &category);
|
||||
|
||||
/// @brief Runs the snapshot test
|
||||
///
|
||||
/// If @a updateSnapshots is `false`, this checks that @a got matches the
|
||||
|
||||
Reference in New Issue
Block a user