Skip to content

Commit 6db46ba

Browse files
authored
Test on Travis (#33)
* Test on Travis * Use old Rebar syntax * Use localhost for Elasticsearch service * Fix Hackney URL * Revert mapping change that is out of this PR's scope * Set required params * Set psql permissions * Use atom keys
1 parent 970b8d5 commit 6db46ba

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

.travis.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: erlang
2+
otp_release:
3+
- 20.2
4+
- 18.0
5+
6+
services:
7+
- elasticsearch
8+
- postgresql
9+
10+
before_script:
11+
- psql -c 'CREATE USER zotonic; ALTER USER zotonic CREATEDB;' -U postgres
12+
13+
script:
14+
- git clone https://github.com/zotonic/zotonic.git /opt/zotonic --branch 0.x
15+
- mkdir -p /opt/zotonic/user/modules ~/.zotonic
16+
- cp travis/zotonic.config ~/.zotonic/
17+
- ln -s $TRAVIS_BUILD_DIR /opt/zotonic/user/modules/
18+
- cd /opt/zotonic
19+
- make all
20+
- bin/zotonic runtests mod_elasticsearch

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
mod_elasticsearch
22
=================
33

4+
[![Build Status](https://travis-ci.com/driebit/mod_elasticsearch.svg?branch=master)](https://travis-ci.com/driebit/mod_elasticsearch)
5+
46
Installation
57
------------
68

support/elasticsearch_mapping.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
]).
1414

1515
%% Map a Zotonic resource
16-
-spec map_rsc(m_rsc:rid(), z:context()) -> lists:proplist().
16+
-spec map_rsc(m_rsc:rid(), z:context()) -> proplists:proplist().
1717
map_rsc(Id, Context) ->
1818
Props = m_rsc:get(Id, Context),
1919
[

tests/mod_elasticsearch_tests.erl

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-module(mod_elasticsearch_tests).
2+
3+
-include_lib("eunit/include/eunit.hrl").
4+
-include_lib("zotonic.hrl").
5+
-include_lib("../include/elasticsearch.hrl").
6+
7+
map_test() ->
8+
{ok, Id} = m_rsc:insert(
9+
[
10+
{category, text},
11+
{title, <<"Just a title">>},
12+
{empty_string, <<"">>}
13+
],
14+
z_acl:sudo(context())
15+
),
16+
Mapped = elasticsearch_mapping:map_rsc(Id, context()),
17+
?assertEqual(<<"Just a title">>, proplists:get_value(title, Mapped)),
18+
?assertEqual(<<"">>, proplists:get_value(empty_string, Mapped)).
19+
20+
context() ->
21+
z_context:new(testsandboxdb).

travis/zotonic.config

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[{zotonic, [
2+
{user_modules_dir, "/opt/zotonic/user/modules"},
3+
{user_sites_dir, "/opt/zotonic/user/sites"},
4+
{deps, [
5+
{erlastic_search, ".*", {git, "https://github.com/tsloughter/erlastic_search.git", "9a207d1ec461103767d9fe28de22f622060f439e"}},
6+
{hackney, ".*", {git, "https://github.com/benoitc/hackney.git", {tag, "1.14.3"}}},
7+
{jsx, ".*", {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
8+
]}
9+
]}].

0 commit comments

Comments
 (0)