Navigation Menu

Skip to content

Commit

Permalink
Fix bugs around auto migration
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 13, 2012
1 parent 3cebd96 commit 67c79d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 128 deletions.
2 changes: 1 addition & 1 deletion lib/batch/processor.js
Expand Up @@ -104,7 +104,7 @@ Processor.prototype = {
if (!field.multipleValues)
field.upgradeToMultipleValuesSync();
}
});
}, this);
this.domain.addRecordSync(record);
results.adds++;
break;
Expand Down
52 changes: 11 additions & 41 deletions test/batch-processor.test.js
Expand Up @@ -80,66 +80,36 @@ suite('batch/processor/Processor (instance methods)', function() {
});

test('loadSync: auto migration to multiple values field', function() {
var field = processor.domain.getIndexField('product');
assert.isFalse(field.multipleValues);

var batches = fs.readFileSync(__dirname + '/fixture/companies/add-multiple-values.sdf.json', 'UTF-8');
batches = JSON.parse(batches);
var result = processor.loadSync(batches);

var field = processor.domain.getIndexField('product');
assert.isTrue(field.multipleValues);

var dump = [
{ id: 'id1',
name: 'Brazil',
description: '',
address: 'Shibuya, Tokyo, Japan',
email_address: 'info@razil.jp',
age: 1,
email_address: 'info@razil.jp',
product: ['moritapo','groonga'] },
{ id: 'id2',
name: 'Enishi Tech Inc.',
address: 'Sapporo, Hokkaido, Japan',
email_address: 'info@enishi-tech.com',
age: 2,
product: ['nroonga','groonga'] },
{ id: 'id3',
name: 'ClearCode Inc.',
address: 'Hongo, Tokyo, Japan',
email_address: 'info@clear-code.com',
age: 3,
product: ['cutter','groonga'] },
{ id: 'id4',
name: 'Anaheim Electronics',
address: 'Granada, Moon',
age: 4,
product: ['hi-zack','gundam'] },
{ id: 'id5',
name: 'Shinsei Industry',
address: 'Earth',
age: 5,
product: ['valkyrie'] },
{ type: 'add',
{ id: 'id6',
name: 'Omni Consumer Products',
description: '',
description: '',
address: 'Detroit and Delta City, Michigan, United States',
age: 6,
email_address: '',
product: ['robocop'] },
{ id: 'id7',
name: 'Capsule Corporation',
address: ['West City'],
age: 7,
product: ['time machine'] },
{ id: 'id8',
name: 'Stark Industries',
address: 'United States',
age: 8,
product: ['iron man'] },
{ id: 'id9',
name: 'Umbrella Corporation',
address: 'Tokyo, Japan',
age: 9,
product: ['tyrant'] },
{ id: 'id10',
name: 'U.S. Robots and Mechanical Men',
description: '',
address: 'New York, United States',
age: 10,
email_address: '',
product: ['ndr114'] }
];
assertSuccess(result, 10, 0, dump);
Expand Down
86 changes: 0 additions & 86 deletions test/fixture/companies/add-multiple-values.sdf.json
Expand Up @@ -12,56 +12,6 @@
"product": ["moritapo","groonga"]
}
},
{
"type": "add",
"id": "id2",
"version": 1,
"lang": "en",
"fields": {
"name": "Enishi Tech Inc.",
"address": "Sapporo, Hokkaido, Japan",
"email_address": "info@enishi-tech.com",
"age": 2,
"product": ["nroonga","groonga"]
}
},
{
"type": "add",
"id": "id3",
"version": 1,
"lang": "en",
"fields": {
"name": "ClearCode Inc.",
"address": "Hongo, Tokyo, Japan",
"email_address": "info@clear-code.com",
"age": 3,
"product": ["cutter","groonga"]
}
},
{
"type": "add",
"id": "id4",
"version": 1,
"lang": "en",
"fields": {
"name": "Anaheim Electronics",
"address": "Granada, Moon",
"age": 4,
"product": ["hi-zack","gundam"]
}
},
{
"type": "add",
"id": "id5",
"version": 1,
"lang": "en",
"fields": {
"name": "Shinsei Industry",
"address": "Earth",
"age": 5,
"product": "valkyrie"
}
},
{
"type": "add",
"id": "id6",
Expand All @@ -74,42 +24,6 @@
"product": "robocop"
}
},
{
"type": "add",
"id": "id7",
"version": 1,
"lang": "en",
"fields": {
"name": "Capsule Corporation",
"address": "West City",
"age": 7,
"product": "time machine"
}
},
{
"type": "add",
"id": "id8",
"version": 1,
"lang": "en",
"fields": {
"name": "Stark Industries",
"address": "United States",
"age": 8,
"product": "iron man"
}
},
{
"type": "add",
"id": "id9",
"version": 1,
"lang": "en",
"fields": {
"name": "Umbrella Corporation",
"address": "Tokyo, Japan",
"age": 9,
"product": "tyrant"
}
},
{
"type": "add",
"id": "id10",
Expand Down

0 comments on commit 67c79d0

Please sign in to comment.