Kai 44fd2a6871
Add Phoenix + Ecto example (#60)
* Boostrap Phoenix application from mix phx.new

* Add opentelemetry dependencies

* Setup opentelemetry for local env

* Setup Dockerfile, docker-compose and otel config

* Configure runtime config for exporter to export to otel collector in prod env

* Generate Posts HTML resources

* Add Release module to run migration in release

* Generate Users LiveView resource

* Add exporter configuration to export directly to external service

* Update README.md to include description and instructions

* Update README.md to include more details on exporting traces

* Fix otlp collector deprecated ports as suggested
2022-02-25 18:45:46 -07:00

60 lines
1.7 KiB
Elixir

defmodule Demo.AccountsTest do
use Demo.DataCase
alias Demo.Accounts
describe "users" do
alias Demo.Accounts.User
import Demo.AccountsFixtures
@invalid_attrs %{name: nil}
test "list_users/0 returns all users" do
user = user_fixture()
assert Accounts.list_users() == [user]
end
test "get_user!/1 returns the user with given id" do
user = user_fixture()
assert Accounts.get_user!(user.id) == user
end
test "create_user/1 with valid data creates a user" do
valid_attrs = %{name: "some name"}
assert {:ok, %User{} = user} = Accounts.create_user(valid_attrs)
assert user.name == "some name"
end
test "create_user/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Accounts.create_user(@invalid_attrs)
end
test "update_user/2 with valid data updates the user" do
user = user_fixture()
update_attrs = %{name: "some updated name"}
assert {:ok, %User{} = user} = Accounts.update_user(user, update_attrs)
assert user.name == "some updated name"
end
test "update_user/2 with invalid data returns error changeset" do
user = user_fixture()
assert {:error, %Ecto.Changeset{}} = Accounts.update_user(user, @invalid_attrs)
assert user == Accounts.get_user!(user.id)
end
test "delete_user/1 deletes the user" do
user = user_fixture()
assert {:ok, %User{}} = Accounts.delete_user(user)
assert_raise Ecto.NoResultsError, fn -> Accounts.get_user!(user.id) end
end
test "change_user/1 returns a user changeset" do
user = user_fixture()
assert %Ecto.Changeset{} = Accounts.change_user(user)
end
end
end