Skip to content

Commit

Permalink
fix: snapshot diff filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Dup4 committed Apr 14, 2022
1 parent 79aec98 commit 2a00789
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 4 additions & 7 deletions include/snapshot/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,14 @@ class Snapshot {

const auto before_content = StringUtility::ToString(before);
const auto after_content = StringUtility::ToString(after);
const auto before_content_target_file =
StringUtility::Join({"/tmp", getSnapshotDiffBeforeFilename(filename_split.back())}, '/');
const auto after_content_target_file =
StringUtility::Join({"/tmp", getSnapshotDiffAfterFilename(filename_split.back())}, '/');
const auto before_content_target_file = StringUtility::Join(
{"/tmp", getSnapshotDiffBeforeFilename(StringUtility::Split(snapshot_key, '/').back())}, '/');
const auto after_content_target_file = StringUtility::Join(
{"/tmp", getSnapshotDiffAfterFilename(StringUtility::Split(snapshot_key, '/').back())}, '/');

FileUtility::RewriteFile(before_content_target_file, before_content);
FileUtility::RewriteFile(after_content_target_file, after_content);

std::cout << before_content_target_file << std::endl;
std::cout << after_content_target_file << std::endl;

const auto diff_content = SystemUtility::Diff(before_content_target_file, after_content_target_file);

FileUtility::RemoveFile(before_content_target_file);
Expand Down
12 changes: 11 additions & 1 deletion test/file_utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ class FileUtilityTest : public testing::Test {
public:
};

TEST_F(FileUtilityTest, get_all_lines) {}
TEST_F(FileUtilityTest, get_all_lines) {
const std::string a = R"(
"foo": bar
)";

const std::string b = R"(
"foo": bar2
)";

SNAPSHOT_DIFF(a, b);
}

0 comments on commit 2a00789

Please sign in to comment.