[tarantool-patches] Re: [PATCH 1/3] Do not force login/pass in URI

Alex Khatskevich avkhatskevich at tarantool.org
Tue Jun 26 00:56:40 MSK 2018


>>
>> diff --git a/test/unit/config.result b/test/unit/config.result
>> index 6b4f87b..847536c 100644
>> --- a/test/unit/config.result
>> +++ b/test/unit/config.result
>> @@ -506,3 +506,17 @@ _ = lcfg.check(cfg)
>>   replica.name = 'storage'
>>   ---
>>   ...
>> +-- gh-47: Check uri
>> +_, err = pcall(lcfg.check_uri, 'invalid uri')
>> +---
>> +...
>> +err:match('Invalid URI.*')
>
> 1. Please, use util.check_error instead of pcall + match as
> I told you earlier.
>
done
>> diff --git a/vshard/cfg.lua b/vshard/cfg.lua
>> index f5db4c0..5644d2c 100644
>> --- a/vshard/cfg.lua
>> +++ b/vshard/cfg.lua
>> @@ -5,10 +5,8 @@ local luri = require('uri')
>>   local consts = require('vshard.consts')
>>     local function check_uri(uri)
>> -    uri = luri.parse(uri)
>> -    if uri.login == nil or uri.password == nil then
>> -        error('URI must contain login and password')
>> -    end
>> +    local parsed = luri.parse(uri)
>> +    assert(parsed, 'Invalid URI: ' .. uri)
>
> 2. Please, do not assertions for regular errors. Use 'error()'.
done
>
>>   end
>>     local function check_master(master, ctx)
>> @@ -251,5 +249,6 @@ end
>>     return {
>>       check = cfg_check,
>> +    check_uri = check_uri,
>
> 3. Do not expose this one-line function for testing only. Just
> use cfg.check for this corrupting an uri of a replica in cfg.
>
> And restore back after the test.
done




More information about the Tarantool-patches mailing list