Merge branch 'fix-rust-warnings' into 'master'

Up tool versions, fix warnings on rustler and add basic test

See merge request jnylen/xler!2
This commit is contained in:
Joakim Nylén 2019-08-23 03:16:03 +00:00
commit 40f3b97901
4 changed files with 38 additions and 7 deletions

View File

@ -1,2 +1,2 @@
erlang 20.0 erlang 21.0
elixir 1.9.0-otp-20 elixir 1.9.0-otp-21

View File

@ -1,6 +1,6 @@
#[macro_use] extern crate rustler; #[macro_use] extern crate rustler;
#[macro_use] extern crate rustler_codegen; extern crate rustler_codegen;
#[macro_use] extern crate lazy_static; extern crate lazy_static;
extern crate calamine; extern crate calamine;
use rustler::{Env, NifResult, Encoder, Term, SchedulerFlags}; use rustler::{Env, NifResult, Encoder, Term, SchedulerFlags};

BIN
test/data/sample.xlsx Normal file

Binary file not shown.

View File

@ -1,8 +1,39 @@
defmodule XlerTest do defmodule XlerTest do
use ExUnit.Case use ExUnit.Case
doctest Xler # doctest Xler
test "greets the world" do def file(), do: File.cwd!() <> "/test/data/sample.xlsx"
assert Xler.hello() == :world
test "can read worksheets from xlsx file" do
assert Xler.worksheets(file()) == {:ok, ["Sheet1"]}
end
test "gets a list of data returned via the worksheet name" do
{:ok, data} = Xler.parse(file(), "Sheet1")
assert length(data) == 701
end
test "returns the correct first row" do
{:ok, data} = Xler.parse(file(), "Sheet1")
assert data |> List.first() == [
"Segment",
"Country",
"Product",
"Discount Band",
"Units Sold",
"Manufacturing Price",
"Sale Price",
"Gross Sales",
"Discounts",
" Sales",
"COGS",
"Profit",
"Date",
"Month Number",
"Month Name",
"Year"
]
end end
end end