Skip to content

Commit

Permalink
Fixes for elixir 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
benrom committed Jan 27, 2017
1 parent abfd8fe commit 14263d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ defmodule ExStatsD.Mixfile do
[app: :ex_statsd,
version: "0.5.3",
elixir: "~> 1.0",
package: package,
deps: deps,
package: package(),
deps: deps(),
# Documentation
name: "ex_statsd",
source_url: "https://github.com/CargoSense/ex_statsd",
Expand Down
16 changes: 8 additions & 8 deletions test/lib/ex_statsd/decorator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ defmodule ExStatsD.DecoratorTest do
test "basic wrapper with defaults" do
assert DecoratedModule.simple === :simple
expected = [@prefix<>"simple_0:1.234|ms"]
assert sent == expected
assert sent() == expected
end

test "custom metric name" do
assert DecoratedModule.custom_name === :custom_name
expected = ["test.custom_key:1.234|ms"]
assert sent == expected
assert sent() == expected
end

test "custom metric name does not leak to next function" do
Expand All @@ -75,7 +75,7 @@ defmodule ExStatsD.DecoratorTest do
@prefix<>"custom_name_gone_0:1.234|ms",
"test.custom_key:1.234|ms"
]
assert sent == expected
assert sent() == expected
end

test "custom metric name falling to next in match unless changed" do
Expand All @@ -87,7 +87,7 @@ defmodule ExStatsD.DecoratorTest do
"test.multi_0_or_1:1.234|ms",
"test.multi_0_or_1:1.234|ms"
]
assert sent == expected
assert sent() == expected
end

test "tags are set and don't leak" do
Expand All @@ -97,7 +97,7 @@ defmodule ExStatsD.DecoratorTest do
@prefix<>"options_gone_0:1.234|ms",
@prefix<>"with_options_0:1.234|ms|#mytag"
]
assert sent == expected
assert sent() == expected
end

test "tags fall through and get updated" do
Expand All @@ -109,7 +109,7 @@ defmodule ExStatsD.DecoratorTest do
@prefix<>"multi_options_1:1.234|ms|#options_fall_through",
@prefix<>"multi_options_1:1.234|ms|#options_fall_through",
]
assert sent == expected
assert sent() == expected
end

test "send using histogram when enabled in all following functions" do
Expand All @@ -119,7 +119,7 @@ defmodule ExStatsD.DecoratorTest do
@prefix<>"multi_attrs_3:1.234|h",
@prefix<>"multi_attrs_2:1.234|h"
]
assert sent == expected
assert sent() == expected
end

test "default options can be changed" do
Expand All @@ -129,7 +129,7 @@ defmodule ExStatsD.DecoratorTest do
@prefix<>"unbound_attr_1:1.234|h|#mine",
@prefix<>"ignored_attr_1:1.234|h|#mine"
]
assert sent == expected
assert sent() == expected
end

defp sent, do: :sys.get_state(ExStatsD).sink
Expand Down
40 changes: 20 additions & 20 deletions test/lib/ex_statsd_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule ExStatsDTest do

{:ok, _pid} = ExStatsD.start_link(options)

assert state.port == port
assert state().port == port
end

test "override host through options" do
Expand All @@ -26,7 +26,7 @@ defmodule ExStatsDTest do

{:ok, _pid} = ExStatsD.start_link(options)

assert state.host == String.to_atom(host)
assert state().host == String.to_atom(host)
end

test "override namespace through options" do
Expand All @@ -35,7 +35,7 @@ defmodule ExStatsDTest do

{:ok, _pid} = ExStatsD.start_link(options)

assert state.namespace == namespace
assert state().namespace == namespace
end

test "override sink through options" do
Expand All @@ -44,14 +44,14 @@ defmodule ExStatsDTest do

{:ok, _pid} = ExStatsD.start_link(options)

assert state.sink == sink
assert state().sink == sink
end

test "transmits data through correct server" do
options = [name: :the_name]
{:ok, _pid} = ExStatsD.start_link(options)

values = 1..100 |> ExStatsD.count("items", options)
_values = 1..100 |> ExStatsD.count("items", options)

assert sent(:the_name) == ["test.items:100|c"]
end
Expand All @@ -65,43 +65,43 @@ defmodule ExStatsDTest do

test "count (in pipeline)" do
values = 1..100 |> ExStatsD.count("items")
assert sent == ["test.items:100|c"]
assert sent() == ["test.items:100|c"]
assert values == 1..100
end

test "counter (in pipeline)" do
value = 3 |> ExStatsD.counter("items")
assert sent == ["test.items:3|c"]
assert sent() == ["test.items:3|c"]
assert value == 3
end

test "gauge (in pipeline)" do
value = 3 |> ExStatsD.gauge("items")
assert sent == ["test.items:3|g"]
assert sent() == ["test.items:3|g"]
assert value == 3
end

test "increment" do
ExStatsD.increment("events")
assert sent == ["test.events:1|c"]
assert sent() == ["test.events:1|c"]
ExStatsD.increment("events", sample_rate: 0.15)
end

test "increment with tags" do
ExStatsD.increment("events", tags: ["foo", "bar"])
assert sent == ["test.events:1|c|#foo,bar"]
assert sent() == ["test.events:1|c|#foo,bar"]
ExStatsD.increment("events", sample_rate: 0.15)
end

test "decrement" do
ExStatsD.decrement("events")
assert sent == ["test.events:-1|c"]
assert sent() == ["test.events:-1|c"]
ExStatsD.decrement("events", sample_rate: 0.15)
end

test "decrement with tags" do
ExStatsD.decrement("events", tags: ["foo", "bar"])
assert sent == ["test.events:-1|c|#foo,bar"]
assert sent() == ["test.events:-1|c|#foo,bar"]
ExStatsD.decrement("events", sample_rate: 0.15)
end

Expand All @@ -112,49 +112,49 @@ defmodule ExStatsDTest do

test "timer" do
value = 12 |> ExStatsD.timer("fun.elapsed")
assert sent == ["test.fun.elapsed:12|ms"]
assert sent() == ["test.fun.elapsed:12|ms"]
assert value == 12
end

test "timer with tags" do
value = 12 |> ExStatsD.timer("fun.elapsed", tags: ["foo", "bar"])
assert sent == ["test.fun.elapsed:12|ms|#foo,bar"]
assert sent() == ["test.fun.elapsed:12|ms|#foo,bar"]
assert value == 12
end

test "gauge" do
value = 11 |> ExStatsD.gauge("fun.thing")
assert sent == ["test.fun.thing:11|g"]
assert sent() == ["test.fun.thing:11|g"]
assert value == 11
end

test "gauge with tags" do
value = 11 |> ExStatsD.gauge("fun.thing", tags: ["foo", "bar"])
assert sent == ["test.fun.thing:11|g|#foo,bar"]
assert sent() == ["test.fun.thing:11|g|#foo,bar"]
assert value == 11
end

test "set" do
value = 1 |> ExStatsD.set("users.ids")
assert sent == ["test.users.ids:1|s"]
assert sent() == ["test.users.ids:1|s"]
assert value == 1
end

test "set with tags" do
value = 1 |> ExStatsD.set("users.ids", tags: ["foo", "bar"])
assert sent == ["test.users.ids:1|s|#foo,bar"]
assert sent() == ["test.users.ids:1|s|#foo,bar"]
assert value == 1
end

test "histogram" do
value = 42 |> ExStatsD.histogram("histogram")
assert sent == ["test.histogram:42|h"]
assert sent() == ["test.histogram:42|h"]
assert value == 42
end

test "histogram with tags" do
value = 42 |> ExStatsD.histogram("histogram", tags: ["foo", "bar"])
assert sent == ["test.histogram:42|h|#foo,bar"]
assert sent() == ["test.histogram:42|h|#foo,bar"]
assert value == 42
end

Expand Down

0 comments on commit 14263d0

Please sign in to comment.