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

This commit is contained in:
Joakim Nylen 2019-08-23 05:15:22 +02:00
parent c667c55db8
commit 1818b0b13a
4 changed files with 38 additions and 7 deletions

View File

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

View File

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

BIN
test/data/sample.xlsx Normal file

Binary file not shown.

View File

@ -1,8 +1,39 @@
defmodule XlerTest do
use ExUnit.Case
doctest Xler
# doctest Xler
test "greets the world" do
assert Xler.hello() == :world
def file(), do: File.cwd!() <> "/test/data/sample.xlsx"
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