Skip to content

Commit eeb175a

Browse files
ligurioTotktonada
authored andcommitted
test: introduce a function to compare versions
- add a function that compares provided curl's version with used one - print a used curl version Needed for #70
1 parent 9335200 commit eeb175a

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

test/smtp.test.lua

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
#!/usr/bin/env tarantool
22

33
local tap = require('tap')
4-
local client = require('smtp').new()
54
local test = tap.test("curl")
5+
local smtp = require('smtp')
66
local fiber = require('fiber')
77
local socket = require('socket')
88
local os = require('os')
99
local log = require('log')
1010

11+
local client = smtp.new()
12+
13+
local SEMVER_RE = '(%d+)%.(%d+)%.(%d+)'
14+
15+
local function curl_version()
16+
local curl_version_str = smtp._CURL_VERSION
17+
local major, minor, patch = string.match(curl_version_str, SEMVER_RE)
18+
return tonumber(major), tonumber(minor), tonumber(patch)
19+
end
20+
21+
-- Whether current curl version is greater or equal to the provided one.
22+
local function is_curl_version_ge(maj, min, patch)
23+
local cur_maj, cur_min, cur_patch = curl_version()
24+
25+
if cur_maj < maj then return false end
26+
if cur_maj > maj then return true end
27+
28+
if cur_min < min then return false end
29+
if cur_min > min then return true end
30+
31+
if cur_patch < patch then return false end
32+
if cur_patch > patch then return true end
33+
34+
return true
35+
end
36+
37+
test:diag(string.format('libcurl version: %s', smtp._CURL_VERSION))
1138
test:plan(1)
1239
local mails = fiber.channel(100)
1340

0 commit comments

Comments
 (0)