Skip to content

Commit

Permalink
diff: enable using diff when there is no cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr. Outis committed Jan 27, 2020
1 parent 6ef90f5 commit bb22acd
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/func/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import json
import os
import pytest
import shutil

import colorama

from dvc.main import main
from dvc.compat import fspath
from dvc.exceptions import DvcException
from dvc.main import main


def digest(text):
Expand All @@ -23,33 +25,40 @@ def test_no_scm(tmp_dir, dvc):
def test_added(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "text")

result = {
assert dvc.diff() == {
"added": [{"filename": "file", "checksum": digest("text")}],
"deleted": [],
"modified": [],
}

assert result == dvc.diff()

def test_no_cache_entry(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "text")
shutil.rmtree(fspath(tmp_dir / ".dvc" / "cache"))

assert dvc.diff() == {
"added": [{"filename": "file", "checksum": digest("text")}],
"deleted": [],
"modified": [],
}


def test_deleted(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "text", commit="add file")
(tmp_dir / "file.dvc").unlink()

result = {
assert dvc.diff() == {
"added": [],
"deleted": [{"filename": "file", "checksum": digest("text")}],
"modified": [],
}

assert result == dvc.diff()


def test_modified(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "first", commit="first version")
tmp_dir.dvc_gen("file", "second")

result = {
assert dvc.diff() == {
"added": [],
"deleted": [],
"modified": [
Expand All @@ -60,8 +69,6 @@ def test_modified(tmp_dir, scm, dvc):
],
}

assert result == dvc.diff()


def test_refs(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "first", commit="first version")
Expand Down

0 comments on commit bb22acd

Please sign in to comment.