mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 07:18:31 +01:00
diff: add JSON output
This commit is contained in:
+19
-10
@@ -1,7 +1,10 @@
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from dvc.main import main
|
||||
|
||||
|
||||
def digest(text):
|
||||
return hashlib.md5(bytes(text, "utf-8")).hexdigest()
|
||||
@@ -126,7 +129,7 @@ def test_directories(tmp_dir, scm, dvc):
|
||||
assert dvc.diff(":/init", ":/directory") == {
|
||||
"added": [
|
||||
{
|
||||
"filename": os.path.dir("dir", ""),
|
||||
"filename": os.path.join("dir", ""),
|
||||
"checksum": "5fb6b29836c388e093ca0715c872fe2a.dir",
|
||||
},
|
||||
{"filename": os.path.join("dir", "1"), "checksum": digest("1")},
|
||||
@@ -179,13 +182,19 @@ def test_cli(tmp_dir, scm, dvc):
|
||||
pytest.skip("TODO: define output structure")
|
||||
|
||||
|
||||
def test_json(tmp_dir, scm, dvc):
|
||||
# result = {
|
||||
# "added": {...},
|
||||
# "renamed": {...},
|
||||
# "modified": {...},
|
||||
# "deleted": {...},
|
||||
# }
|
||||
def test_json(tmp_dir, scm, dvc, capsys):
|
||||
assert 0 == main(["diff", "--json"])
|
||||
assert not capsys.readouterr().out
|
||||
|
||||
# main(["diff", "--json"])
|
||||
pytest.skip("TODO: define output structure")
|
||||
tmp_dir.dvc_gen("file", "text")
|
||||
assert 0 == main(["diff", "--json"])
|
||||
assert (
|
||||
json.dumps(
|
||||
{
|
||||
"added": [{"filename": "file", "checksum": digest("text")}],
|
||||
"deleted": [],
|
||||
"modified": [],
|
||||
}
|
||||
)
|
||||
in capsys.readouterr().out
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user