Skip to content

Instantly share code, notes, and snippets.

@steffen-workpath
Created March 13, 2022 09:28
Show Gist options
  • Save steffen-workpath/e66184e671a6019025704ee2dfe64797 to your computer and use it in GitHub Desktop.
Save steffen-workpath/e66184e671a6019025704ee2dfe64797 to your computer and use it in GitHub Desktop.
defmodule KeyResultTest do
use ExUnit.Case
doctest KeyResult
test "calculates progress for binary KRs" do
assert KeyResult.progress(%KeyResult{done: true}) == 1
assert KeyResult.progress(%KeyResult{done: false}) == 0
end
test "calculates progress for metrics KRs" do
assert KeyResult.progress(%KeyResult{start: 0.0, target: 1.0, actual: 0.5}) == 0.5
assert KeyResult.progress(%KeyResult{start: 0.0, target: 10.0, actual: 5.0}) == 0.5
assert KeyResult.progress(%KeyResult{start: 0.0, target: 100.0, actual: 200.0}) == 2.0
end
end
defmodule GoalTest do
use ExUnit.Case
doctest Goal
test "calculates progress for goals" do
g = %Goal{
krs: [
%KeyResult{desc: "Do hackathon", done: true},
%KeyResult{desc: "Get 100 claps on Medium post", start: 0, target: 100, actual: 0}
]
}
assert Goal.progress(g) == 0.5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment