Skip to content

Commit 9eb43f4

Browse files
committed
feat(governance): add automated tesst for network requests
should enable us to test the requests one by one and ensure we decode properly the replies Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
1 parent 49c5288 commit 9eb43f4

8 files changed

Lines changed: 552 additions & 2 deletions

src/gui/governance/applygovernancelabel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ void ApplyGovernanceLabel::start()
2121

2222
connect(ocsGovernanceJob().data(), &OcsJob::jobFinished,
2323
this, &ApplyGovernanceLabel::jobDone);
24+
connect(ocsGovernanceJob().data(), &OcsJob::ocsError,
25+
this, &ApplyGovernanceLabel::finishedWitherror);
2426

2527
ocsGovernanceJob()->setPath(buildPath());
2628
ocsGovernanceJob()->setMethod("POST");
@@ -35,7 +37,6 @@ void ApplyGovernanceLabel::jobDone(QJsonDocument reply, int statusCode)
3537

3638
qCInfo(lcGovernance) << reply;
3739

38-
3940
Q_EMIT finished();
4041
}
4142

src/gui/governance/deletegovernancelabel.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ void DeleteGovernanceLabel::start()
2121

2222
connect(ocsGovernanceJob().data(), &OcsJob::jobFinished,
2323
this, &DeleteGovernanceLabel::jobDone);
24+
connect(ocsGovernanceJob().data(), &OcsJob::ocsError,
25+
this, &DeleteGovernanceLabel::ocsError);
2426

2527
ocsGovernanceJob()->setPath(buildPath());
2628
ocsGovernanceJob()->setMethod("DELETE");
@@ -39,4 +41,14 @@ void DeleteGovernanceLabel::jobDone(QJsonDocument reply, int statusCode)
3941
Q_EMIT finished();
4042
}
4143

44+
void DeleteGovernanceLabel::ocsError(int statusCode, const QString &message)
45+
{
46+
Q_UNUSED(message)
47+
Q_UNUSED(statusCode)
48+
49+
qCInfo(lcGovernance) << message;
50+
51+
Q_EMIT finished();
52+
}
53+
4254
} // namespace OCC

src/gui/governance/deletegovernancelabel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public Q_SLOTS:
2727

2828
private Q_SLOTS:
2929
void jobDone(QJsonDocument reply, int statusCode);
30+
31+
void ocsError(int statusCode, const QString &message);
3032
};
3133

3234
} // namespace OCC

src/gui/governance/getavailablegovernancelabels.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ void GetAvailableGovernanceLabels::start()
2323

2424
connect(ocsGovernanceJob().data(), &OcsJob::jobFinished,
2525
this, &GetAvailableGovernanceLabels::jobDone);
26+
connect(ocsGovernanceJob().data(), &OcsJob::ocsError,
27+
this, &GetAvailableGovernanceLabels::finishedWitherror);
2628

2729
ocsGovernanceJob()->setPath(buildPath());
2830
ocsGovernanceJob()->setMethod("GET");

src/gui/governance/getgovernancelabels.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ void GetGovernanceLabels::start()
2121

2222
connect(ocsGovernanceJob().data(), &OcsJob::jobFinished,
2323
this, &GetGovernanceLabels::jobDone);
24+
connect(ocsGovernanceJob().data(), &OcsJob::ocsError,
25+
this, &GetGovernanceLabels::finishedWitherror);
2426

2527
ocsGovernanceJob()->setPath(buildPath());
2628
ocsGovernanceJob()->setMethod("GET");
@@ -35,7 +37,6 @@ void GetGovernanceLabels::jobDone(QJsonDocument reply, int statusCode)
3537

3638
qCInfo(lcGovernance) << reply;
3739

38-
3940
Q_EMIT finished();
4041
}
4142

src/gui/governance/governancenetworkjob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class GovernanceNetworkJob : public QObject
8989

9090
void finished();
9191

92+
void finishedWitherror(int errorCode, const QString &errorMessage);
93+
9294
void accountChanged();
9395

9496
protected:

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ nextcloud_add_test(AllFilesDeleted)
7777
nextcloud_add_test(Blacklist)
7878
nextcloud_add_test(LocalDiscovery)
7979
nextcloud_add_test(RemoteDiscovery)
80+
nextcloud_add_test(Governance)
8081

8182
if (NOT APPLE)
8283
nextcloud_add_test(Permissions)

0 commit comments

Comments
 (0)