~ubuntu-branches/ubuntu/trusty/mongodb/trusty-proposed

« back to all changes in this revision

Viewing changes to src/mongo/db/fts/fts_spec_test.cpp

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2014-01-16 12:44:01 UTC
  • mfrom: (44.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20140116124401-eak2chp7r2yb1shz
Tags: 1:2.4.9-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
namespace mongo {
25
25
    namespace fts {
26
26
 
 
27
        const BSONObj makeFixedSpec( int textIndexVersion ) {
 
28
            return BSON( "v" << 1 <<
 
29
                         "key" << BSON( "_fts" << "text" <<
 
30
                                        "_ftsx" << 1 ) <<
 
31
                         "name" << "a_text" <<
 
32
                         "ns" << "test.foo" <<
 
33
                         "weights" << BSON( "a" << 1 ) <<
 
34
                         "default_language" << "english" <<
 
35
                         "language_override" << "language" <<
 
36
                         "textIndexVersion" << textIndexVersion );
 
37
        }
 
38
 
 
39
        TEST( FTSSpec, TextIndexVersionCheck1 ) {
 
40
            const int currentVersion = 1;
 
41
            const int unsupportedVersion = 2;
 
42
 
 
43
            // Constructing an FTSSpec with the current textIndexVersion should succeed.
 
44
            BSONObj validTextSpec = makeFixedSpec( currentVersion );
 
45
            try {
 
46
                FTSSpec spec( validTextSpec );
 
47
            }
 
48
            catch ( DBException& e ) {
 
49
                ASSERT( false );
 
50
            }
 
51
 
 
52
            // Constructing an FTSSpec with an unsupported textIndexVersion should fail.
 
53
            BSONObj invalidTextSpec = makeFixedSpec( unsupportedVersion );
 
54
            ASSERT_THROWS( FTSSpec spec( invalidTextSpec ), DBException );
 
55
        }
 
56
 
27
57
        TEST( FTSSpec, Fix1 ) {
28
58
            BSONObj user = BSON( "key" << BSON( "title" << "fts" <<
29
59
                                                "text" << "fts" ) <<