Skip to content

Commit 1b45e33

Browse files
committed
Hash sync test fixture from disk
1 parent b3c97f3 commit 1b45e33

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

test/unittest.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,9 +1960,15 @@ TEST(sqlite_sync_directory_skips_unchanged) {
19601960
mkdir_p(test_dir);
19611961
create_test_file(file, content);
19621962

1963-
// Compute the hash and pre-insert the entry
1964-
uint64_t hash = dbmem_hash_compute(content, strlen(content));
1965-
int rc = insert_fake_content(db, hash, file, "notes", (sqlite3_int64)strlen(content));
1963+
// Compute the hash from disk so Windows text-mode newline translation
1964+
// cannot make the pre-inserted hash differ from memory_add_directory().
1965+
int64_t len = 0;
1966+
char *buf = dbmem_file_read(file, &len);
1967+
ASSERT(buf != NULL);
1968+
uint64_t hash = dbmem_hash_compute(buf, (size_t)len);
1969+
dbmemory_free(buf);
1970+
1971+
int rc = insert_fake_content(db, hash, file, "notes", len);
19661972
ASSERT_EQ(rc, SQLITE_OK);
19671973

19681974
// Sync — file exists with matching hash, should be skipped

0 commit comments

Comments
 (0)