Merge lp:~jonas-drange/ubuntu-system-settings/lp1616800 into lp:ubuntu-system-settings

Proposed by Jonas G. Drange on 2016-08-25
Status: Merged
Approved by: Jonas G. Drange on 2016-08-25
Approved revision: 1703
Merged at revision: 1709
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/lp1616800
Merge into: lp:ubuntu-system-settings
Diff against target: 69 lines (+32/-2)
2 files modified
plugins/system-update/click/manager_impl.cpp (+9/-2)
tests/plugins/system-update/tst_clickmanager.cpp (+23/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/lp1616800
Reviewer Review Type Date Requested Status
Ken VanDine 2016-08-25 Approve on 2016-08-25
system-apps-ci-bot continuous-integration Approve on 2016-08-25
Review via email: mp+303912@code.launchpad.net

Commit message

do not overwrite updatedAt

To post a comment you must log in.

PASSED: Continuous integration, rev:1702
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/130/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1307
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/291
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1307
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1172
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1172
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1172
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1152/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1152
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1152/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/130/rebuild

review: Approve (continuous-integration)
1703. By Jonas G. Drange on 2016-08-25

extend sync test, and add updatedAt for manually installed clicks

Ken VanDine (ken-vandine) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/system-update/click/manager_impl.cpp'
2--- plugins/system-update/click/manager_impl.cpp 2016-08-16 11:42:49 +0000
3+++ plugins/system-update/click/manager_impl.cpp 2016-08-25 12:17:36 +0000
4@@ -302,8 +302,15 @@
5 /* The local version of a click in the manifest, matched exactly a
6 a remote version in one of our db updates. */
7 if (manifestUpdate->localVersion() == dbUpdate->remoteVersion()) {
8- m_model->setInstalled(dbUpdate->identifier(),
9- dbUpdate->revision());
10+ // We can't know when it was updated, so now() will have to do.
11+ if (!dbUpdate->updatedAt().isValid()) {
12+ dbUpdate->setUpdatedAt(QDateTime::currentDateTimeUtc());
13+ }
14+ dbUpdate->setState(Update::State::StateInstallFinished);
15+ dbUpdate->setInstalled(true);
16+ dbUpdate->setDownloadId("");
17+ dbUpdate->setError("");
18+ m_model->update(dbUpdate);
19 found = true;
20 } else if (manifestUpdate->identifier() == dbUpdate->identifier()) {
21 // Fast forward the local version.
22
23=== modified file 'tests/plugins/system-update/tst_clickmanager.cpp'
24--- tests/plugins/system-update/tst_clickmanager.cpp 2016-08-12 07:40:41 +0000
25+++ tests/plugins/system-update/tst_clickmanager.cpp 2016-08-25 12:17:36 +0000
26@@ -27,6 +27,7 @@
27 #include "plugins/system-update/faketokendownloader.h"
28 #include "plugins/system-update/faketokendownloader_factory.h"
29
30+#include <QDateTime>
31 #include <QDir>
32 #include <QJsonArray>
33 #include <QJsonParseError>
34@@ -276,6 +277,7 @@
35
36 Q_FOREACH(auto update, markedInstalled) {
37 QVERIFY(m_model->get(update)->installed());
38+ QVERIFY(m_model->get(update)->updatedAt().isValid());
39 }
40 Q_FOREACH(auto update, uninstalled) {
41 QVERIFY(!m_model->get(update)->installed());
42@@ -513,6 +515,27 @@
43 {
44 // Verify that a SessionToken is requested even if a check has not run.
45 }
46+ void testSynchronizationDoesNotOverwriteUpdatedAt()
47+ {
48+ // Fix for lp:1616800
49+ auto update = createUpdate("a", 0);
50+ auto updatedAt = QDateTime(QDate(2016, 2, 29), QTime(18, 0), Qt::UTC);
51+ update->setRemoteVersion("v1");
52+ update->setInstalled(true);
53+ update->setUpdatedAt(updatedAt);
54+ m_model->add(update);
55+
56+ /* Trigger synchronization using data to indicate that a.0 was
57+ installed. */
58+ QByteArray manifest("[{"
59+ "\"name\": \"a\","
60+ "\"version\": \"v1\""
61+ "}]");
62+ m_mockmanifest->mockSuccess(JSONfromQByteArray(manifest));
63+
64+ auto dbUpdated = m_model->get("a", 0);
65+ QCOMPARE(update->updatedAt(), dbUpdated->updatedAt());
66+ }
67 private:
68 // Create JSON Array from a QByteArray.
69 QJsonArray JSONfromQByteArray(const QByteArray &byteArray)

Subscribers

People subscribed via source and target branches