Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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