Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ erl_crash.dump
id3-*.tar

# Rustler creates native files inside /priv. We'll ignore that.
/priv/native/*
/priv/native/*

native/id3/.cargo/config

.DS_Store
priv/.DS_Store
Comment on lines +30 to +31
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should go to your local $GIT_DIR/info/exclude or core.excludesFile, since this is specific to macOS systems.
https://git-scm.com/docs/gitignore

Binary file not shown.
53 changes: 50 additions & 3 deletions test/id3v2_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
defmodule ID3Test do
use ExUnit.Case
doctest ID3
# doctest ID3
@path_to_sample_mp3 "priv/sample_mp3/WAKADINALI-Morio-Anzenza-Ft-Dyana-Cods.mp3"

test "greets the world" do
assert ID3.hello() == :world
describe "get_tag" do
test "get_tag!/1: return ID3_struct when valid mp3 path provided" do
assert %ID3.Tag{} = ID3.get_tag!(@path_to_sample_mp3)
end

test "get_tag/1: return {:ok, ID3_struct} when valid mp3 path provided" do
assert {
:ok,
%ID3.Tag{}
} = ID3.get_tag(@path_to_sample_mp3)
end

test "get_tag/1: return error tuple when invalid path provided" do
assert {:error, :file_open_error} = ID3.get_tag("")
end
end

describe "write_tag" do
test "write_tag/2" do
# get file with year: nil
assert {
:ok,
%ID3.Tag{
year: nil
} = tag
} = ID3.get_tag(@path_to_sample_mp3)

# write tag year: 2020
ID3.write_tag(%{tag | year: 2020}, @path_to_sample_mp3)
# assert tag year: 2020
assert {
:ok,
%ID3.Tag{year: 2020} = tag
} = ID3.get_tag(@path_to_sample_mp3)

on_exit(fn ->
IO.puts(
"#{__MODULE__}.on_exit/1 cleaning up test: write_tag/2 -> resetting test file to initial tag"
)

ID3.write_tag(%{tag | year: nil}, @path_to_sample_mp3)

assert {
:ok,
%ID3.Tag{year: nil}
} = ID3.get_tag(@path_to_sample_mp3)
end)
end
end
end