Improved attachment test.

This commit is contained in:
Martin Edenhofer 2015-04-07 01:56:53 +02:00
parent acbe704c3b
commit cfc3e846b6
4 changed files with 12 additions and 12 deletions

View file

@ -1,11 +1,11 @@
# Setup a Elasticsearch # Setup a Elasticsearch
* Install Elasticsearch * Install Elasticsearch
http://www.elasticsearch.org/overview/elkdownloads/ https://www.elastic.co/downloads/elasticsearch
* Install attachment plugin * Install attachment plugin
cd /usr/share/elasticsearch cd /usr/share/elasticsearch
bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.0.0 bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.5.0
* Configure elasticsearch * Configure elasticsearch
/etc/sysconfig/elasticsearch /etc/sysconfig/elasticsearch

View file

@ -9,7 +9,7 @@ Message-Id: <BC182994-03FA-4DC5-8202-98CBFACA0887@example.com>
To: metest@znuny.com To: metest@znuny.com
Mime-Version: 1.0 (Apple Message framework v1257) Mime-Version: 1.0 (Apple Message framework v1257)
=E4=F6=FC=DF ad asd =E4=F6=FC=DF ad asd test99
-Martin -Martin

File diff suppressed because one or more lines are too long

View file

@ -121,7 +121,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add( Store.add(
:object => 'Ticket::Article', :object => 'Ticket::Article',
:o_id => article1.id, :o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-normal.txt"), :data => File.open("#{Rails.root.to_s}/test/fixtures/es-normal.txt", 'rb') { |file| file.read },
:filename => 'es-normal.txt', :filename => 'es-normal.txt',
:preferences => {}, :preferences => {},
:created_by_id => 1, :created_by_id => 1,
@ -132,29 +132,29 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add( Store.add(
:object => 'Ticket::Article', :object => 'Ticket::Article',
:o_id => article1.id, :o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-pdf1.pdf"), :data => File.open("#{Rails.root.to_s}/test/fixtures/es-pdf1.pdf", 'rb') { |file| file.read },
:filename => 'es-pdf1.pdf', :filename => 'es-pdf1.pdf',
:preferences => {}, :preferences => {},
:created_by_id => 1, :created_by_id => 1,
) )
# add attachments which should get index / .box # add attachments which should get index / .box
# "Old programmers never die" # "Old programmers never die test99"
Store.add( Store.add(
:object => 'Ticket::Article', :object => 'Ticket::Article',
:o_id => article1.id, :o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-box1.box"), :data => File.open("#{Rails.root.to_s}/test/fixtures/es-box1.box", 'rb') { |file| file.read },
:filename => 'mail1.box', :filename => 'mail1.box',
:preferences => {}, :preferences => {},
:created_by_id => 1, :created_by_id => 1,
) )
# add to big attachment which should not get index # add to big attachment which should not get index
# "some too big text" # "some too big text88"
Store.add( Store.add(
:object => 'Ticket::Article', :object => 'Ticket::Article',
:o_id => article1.id, :o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-too-big.txt"), :data => File.open("#{Rails.root.to_s}/test/fixtures/es-too-big.txt", 'rb') { |file| file.read },
:filename => 'es-too-big.txt', :filename => 'es-too-big.txt',
:preferences => {}, :preferences => {},
:created_by_id => 1, :created_by_id => 1,
@ -264,14 +264,14 @@ class ElasticsearchTest < ActiveSupport::TestCase
# search for not indexed attachment # search for not indexed attachment
result = Ticket.search( result = Ticket.search(
:current_user => agent, :current_user => agent,
:query => '"some too big text"', :query => 'test88',
:limit => 15, :limit => 15,
) )
assert(!result[0], 'record 1') assert(!result[0], 'record 1')
result = Ticket.search( result = Ticket.search(
:current_user => agent, :current_user => agent,
:query => '"Old programmers never die"', :query => 'test99',
:limit => 15, :limit => 15,
) )
assert(!result[0], 'record 1') assert(!result[0], 'record 1')