This commit is contained in:
zack 2024-10-22 16:51:56 -04:00
parent e2967f68b2
commit ef2a6c41b4
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
39 changed files with 2349 additions and 30 deletions

View file

@ -0,0 +1,61 @@
defmodule Zoeyscomputer.ApiKeysTest do
use Zoeyscomputer.DataCase
alias Zoeyscomputer.ApiKeys
describe "api_keys" do
alias Zoeyscomputer.ApiKeys.ApiKey
import Zoeyscomputer.ApiKeysFixtures
@invalid_attrs %{name: nil, token: nil}
test "list_api_keys/0 returns all api_keys" do
api_key = api_key_fixture()
assert ApiKeys.list_api_keys() == [api_key]
end
test "get_api_key!/1 returns the api_key with given id" do
api_key = api_key_fixture()
assert ApiKeys.get_api_key!(api_key.id) == api_key
end
test "create_api_key/1 with valid data creates a api_key" do
valid_attrs = %{name: "some name", token: "some token"}
assert {:ok, %ApiKey{} = api_key} = ApiKeys.create_api_key(valid_attrs)
assert api_key.name == "some name"
assert api_key.token == "some token"
end
test "create_api_key/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = ApiKeys.create_api_key(@invalid_attrs)
end
test "update_api_key/2 with valid data updates the api_key" do
api_key = api_key_fixture()
update_attrs = %{name: "some updated name", token: "some updated token"}
assert {:ok, %ApiKey{} = api_key} = ApiKeys.update_api_key(api_key, update_attrs)
assert api_key.name == "some updated name"
assert api_key.token == "some updated token"
end
test "update_api_key/2 with invalid data returns error changeset" do
api_key = api_key_fixture()
assert {:error, %Ecto.Changeset{}} = ApiKeys.update_api_key(api_key, @invalid_attrs)
assert api_key == ApiKeys.get_api_key!(api_key.id)
end
test "delete_api_key/1 deletes the api_key" do
api_key = api_key_fixture()
assert {:ok, %ApiKey{}} = ApiKeys.delete_api_key(api_key)
assert_raise Ecto.NoResultsError, fn -> ApiKeys.get_api_key!(api_key.id) end
end
test "change_api_key/1 returns a api_key changeset" do
api_key = api_key_fixture()
assert %Ecto.Changeset{} = ApiKeys.change_api_key(api_key)
end
end
end

View file

@ -0,0 +1,59 @@
defmodule Zoeyscomputer.ImagesTest do
use Zoeyscomputer.DataCase
alias Zoeyscomputer.Images
describe "images" do
alias Zoeyscomputer.Images.Image
import Zoeyscomputer.ImagesFixtures
@invalid_attrs %{file: nil}
test "list_images/0 returns all images" do
image = image_fixture()
assert Images.list_images() == [image]
end
test "get_image!/1 returns the image with given id" do
image = image_fixture()
assert Images.get_image!(image.id) == image
end
test "create_image/1 with valid data creates a image" do
valid_attrs = %{file: "some file"}
assert {:ok, %Image{} = image} = Images.create_image(valid_attrs)
assert image.file == "some file"
end
test "create_image/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Images.create_image(@invalid_attrs)
end
test "update_image/2 with valid data updates the image" do
image = image_fixture()
update_attrs = %{file: "some updated file"}
assert {:ok, %Image{} = image} = Images.update_image(image, update_attrs)
assert image.file == "some updated file"
end
test "update_image/2 with invalid data returns error changeset" do
image = image_fixture()
assert {:error, %Ecto.Changeset{}} = Images.update_image(image, @invalid_attrs)
assert image == Images.get_image!(image.id)
end
test "delete_image/1 deletes the image" do
image = image_fixture()
assert {:ok, %Image{}} = Images.delete_image(image)
assert_raise Ecto.NoResultsError, fn -> Images.get_image!(image.id) end
end
test "change_image/1 returns a image changeset" do
image = image_fixture()
assert %Ecto.Changeset{} = Images.change_image(image)
end
end
end