|
1 | 1 | #!/usr/bin/env tarantool
|
2 | 2 |
|
3 | 3 | local tap = require('tap')
|
4 |
| -local client = require('smtp').new() |
5 | 4 | local test = tap.test("curl")
|
| 5 | +local smtp = require('smtp') |
6 | 6 | local fiber = require('fiber')
|
7 | 7 | local socket = require('socket')
|
8 | 8 | local os = require('os')
|
9 | 9 | local log = require('log')
|
10 | 10 |
|
| 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)) |
11 | 38 | test:plan(1)
|
12 | 39 | local mails = fiber.channel(100)
|
13 | 40 |
|
|
0 commit comments