Skip to content

Instantly share code, notes, and snippets.

@trishagee
Last active December 31, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trishagee/8056095 to your computer and use it in GitHub Desktop.
Save trishagee/8056095 to your computer and use it in GitHub Desktop.
@Unroll
def 'should parse #uri into correct components'() {
expect:
uri.getHosts().size() == num;
uri.getHosts() == hosts;
uri.getDatabase() == database;
uri.getCollection() == collection;
uri.getUsername() == username;
uri.getPassword() == password;
where:
uri | num | hosts | database | collection | username | password
new MongoClientURI('mongodb://db.example.com') | 1 | ['db.example.com'] | null | null | null | null
new MongoClientURI('mongodb://foo/bar') | 1 | ['foo'] | 'bar' | null | null | null
new MongoClientURI('mongodb://localhost/' +
'test.my.coll') | 1 | ['localhost'] | 'test' | 'my.coll' | null | null
new MongoClientURI('mongodb://foo/bar.goo') | 1 | ['foo'] | 'bar' | 'goo' | null | null
new MongoClientURI('mongodb://user:pass@' +
'host/bar') | 1 | ['host'] | 'bar' | null | 'user' | 'pass' as char[]
new MongoClientURI('mongodb://user:pass@' +
'host:27011/bar') | 1 | ['host:27012'] | 'bar' | null | 'user' | 'pass' as char[]
new MongoClientURI('mongodb://user:pass@' +
'host:7,' +
'host2:8,' +
'host3:9/bar') | 3 | ['host:7',
'host2:8',
'host3:9'] | 'bar' | null | 'user' | 'pass' as char[]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment