Closed Bug 557588 Opened 14 years ago Closed 14 years ago

code audit and create unit test plan for engines.js

Categories

(Firefox :: Sync, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mconnor, Assigned: philikon)

References

Details

Attachments

(2 files, 2 obsolete files)

      No description provided.
Target Milestone: --- → 1.3
Flags: blocking-weave1.3+
Whiteboard: [final]
Whiteboard: [final]
Assignee: mconnor → philipp
This is part one containing tests for everything in engine.js apart from SyncEngine.sync(), or rather the methods it calls to perform the sync. These methods rely upon various things to be set up (e.g. private/public key objects, a reasonably complete store implementation, various server methods, etc.). They are probably best tested separately, and it might make sense to come up with some generic test helpers for similar tests (e.g. for service.js).
Attachment #447196 - Flags: review?(mconnor)
Now part two containing

* a few clarifying comments regarding various constants,

* a FakeCryptoService implementation (it basically doesn't encrypt ;)),

* complete server side (httpd.js) implementations for WBOs and Collections,

* exhaustive tests for SyncEngine.sync(), or rather its individual parts.
Attachment #447809 - Flags: review?(mconnor)
Comment on attachment 447196 [details] [diff] [review]
Part 1: Tests for EngineMangerSvc, Engine and SyncEngine sans sync()


>+function test_enabled() {
>+  _("Engine.enabled corresponds to preference");
>+  let engine = new SteamEngine();
>+  try {
>+    do_check_false(!!engine.enabled);
>+    Svc.Prefs.set("engine.steam", true);
>+    do_check_true(!!engine.enabled);

do we really need the !! here and elsewhere?  engine.enabled should return true or false already.
Attachment #447196 - Flags: review?(mconnor) → review+
(In reply to comment #3)
> do we really need the !! here and elsewhere?  engine.enabled should return true
> or false already.

Actually, since the value comes from a preference setting, it will initially be null. So at least the do_check_false() check would need the !!. Using do_check_false() felt more appropriate than explicitly checking for equality to null, since engine.enabled is generally thought to be of boolean nature. You're right about the do_check_true() case, though. I'll get rid of that one.
Do we just want to make the enabled api return a true/false for sure? Do we use it anywhere assuming undefined?/null
(In reply to comment #5)
> Do we just want to make the enabled api return a true/false for sure? Do we use
> it anywhere assuming undefined?/null

No, it seems to be used as a boolean throughout. +1 to making it true/false.
We should do that.  If we have somewhere distinguishing between true/false/null, I will look at blame and laugh.  Or cry.
Comment on attachment 447809 [details] [diff] [review]
Part 2: Tests for SyncEngine.sync(), incl some additions to harness

>diff -r b08ce2c09761 source/modules/constants.js.in

>-// Record size limit is currently 10K, so 100 is a bit over 1MB
>+// Record size limit is currently 28K, so 100 records is a bit over 2.7MB

it's 256k, actually, though the old cluster capped to 28k.  Filed bug 569295 to cover being smart about total upload size.

>diff -r b08ce2c09761 source/modules/engines.js

>-    // Figure out how many total items to fetch this sync; do less on mobile
>+    // Figure out how many total items to fetch this sync; do less on mobile.
>+    // 50 is hardcoded here because of URL length restrictions.
>+    // (GUIDs are 10 chars)

GUIDs are actually up to 64 chars under the 1.0 API.  Right now we can have long things like {9a1154a9-85f6-4e49-aa9f-9c339ab12e45}33 for bookmarks.
Attachment #447809 - Flags: review?(mconnor) → review+
Engine.enabled now always returns a boolean.
Attachment #447196 - Attachment is obsolete: true
http://hg.mozilla.org/labs/weave/rev/ff0b28eef311
Tests for EngineMangerSvc, Engine and SyncEngine sans sync(). 

http://hg.mozilla.org/labs/weave/rev/965642249768
Tests for SyncEngine.sync(), incl some additions to harness.
Status: NEW → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: 1.3 → 2.0
http://hg.mozilla.org/labs/weave/rev/37afbc3db445 (new url from hg magic)
Tests for EngineMangerSvc, Engine and SyncEngine sans sync(). 

http://hg.mozilla.org/labs/weave/rev/fc08fa427202 (new url from hg magic)
Tests for SyncEngine.sync(), incl some additions to harness.
Target Milestone: 2.0 → 1.4
Blocks: 569744
Blocks: 569746
Blocks: 570137
Blocks: 570152
Component: Firefox Sync: Backend → Sync
Product: Cloud Services → Firefox
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: