Skip to content

Commit 857b4af

Browse files
committed
Fix schema cache file test
This test was leaving behind the directory and was never verifying the file existed after dump was called. We can't use a tempfile because it will be created automatically and this is testing that `SchemaCache#open` will create the file if it doesn't exist.
1 parent 6f50d40 commit 857b4af

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

activerecord/test/cases/connection_adapters/schema_cache_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ def test_yaml_dump_and_load
4141

4242
def test_cache_path_can_be_in_directory
4343
cache = SchemaCache.new @connection
44-
filename = "some_dir/schema.json"
44+
tmp_dir = Dir.mktmpdir
45+
filename = File.join(tmp_dir, "schema.json")
46+
47+
assert_not File.exist?(filename)
4548
assert cache.dump_to(filename)
49+
assert File.exist?(filename)
4650
ensure
47-
File.delete(filename)
51+
FileUtils.rm_r(tmp_dir)
4852
end
4953

5054
def test_yaml_dump_and_load_with_gzip

0 commit comments

Comments
 (0)