33require 'test_helper'
44
55class SanityCheckTest < GemTestCase
6- test 'PostgreSQL, MySQL, and Trilogy databases are properly isolated' do
6+ test 'PostgreSQL and MySQL databases are properly isolated' do
77 # Create a tag in PostgreSQL database
88 pg_tag = Tag . create! ( name : 'postgresql-only-tag' )
99
@@ -26,31 +26,9 @@ class SanityCheckTest < GemTestCase
2626 assert_not Tag . exists? ( name : 'mysql-only-tag' )
2727 assert_equal 0 , Tag . where ( name : 'mysql-only-tag' ) . count
2828
29- # Create a tag in Trilogy database
30- trilogy_tag = TrilogyTag . create! ( name : 'trilogy-only-tag' )
31-
32- # Verify it exists in Trilogy
33- assert TrilogyTag . exists? ( name : 'trilogy-only-tag' )
34- assert_equal 1 , TrilogyTag . where ( name : 'trilogy-only-tag' ) . count
35-
36- # Verify it does NOT exist in PostgreSQL or MySQL databases
37- assert_not Tag . exists? ( name : 'trilogy-only-tag' )
38- assert_equal 0 , Tag . where ( name : 'trilogy-only-tag' ) . count
39- assert_not MysqlTag . exists? ( name : 'trilogy-only-tag' )
40- assert_equal 0 , MysqlTag . where ( name : 'trilogy-only-tag' ) . count
41-
42- # Verify PostgreSQL tag does NOT exist in Trilogy
43- assert_not TrilogyTag . exists? ( name : 'postgresql-only-tag' )
44- assert_equal 0 , TrilogyTag . where ( name : 'postgresql-only-tag' ) . count
45-
46- # Verify MySQL tag does NOT exist in Trilogy
47- assert_not TrilogyTag . exists? ( name : 'mysql-only-tag' )
48- assert_equal 0 , TrilogyTag . where ( name : 'mysql-only-tag' ) . count
49-
5029 # Clean up
5130 pg_tag . destroy
5231 mysql_tag . destroy
53- trilogy_tag . destroy
5432 end
5533
5634 test 'PostgreSQL models use PostgreSQL adapter' do
@@ -65,31 +43,68 @@ class SanityCheckTest < GemTestCase
6543 assert_equal 'Mysql2' , MysqlLabel . connection . adapter_name
6644 end
6745
68- test 'Trilogy models use Trilogy adapter' do
69- assert_equal 'Trilogy' , TrilogyTag . connection . adapter_name
70- assert_equal 'Trilogy' , TrilogyTagAudit . connection . adapter_name
71- assert_equal 'Trilogy' , TrilogyLabel . connection . adapter_name
72- end
73-
74- test 'can write to all three databases in same test' do
75- # Create records in all three databases
46+ test 'can write to PostgreSQL and MySQL databases in same test' do
47+ # Create records in both databases
7648 pg_tag = Tag . create! ( name : 'test-pg' )
7749 mysql_tag = MysqlTag . create! ( name : 'test-mysql' )
78- trilogy_tag = TrilogyTag . create! ( name : 'test-trilogy' )
7950
80- # All should have IDs
51+ # Both should have IDs
8152 assert pg_tag . persisted?
8253 assert mysql_tag . persisted?
83- assert trilogy_tag . persisted?
8454
85- # IDs should be independent (all could be 1 if tables are empty)
55+ # IDs should be independent (both could be 1 if tables are empty)
8656 assert_kind_of Integer , pg_tag . id
8757 assert_kind_of Integer , mysql_tag . id
88- assert_kind_of Integer , trilogy_tag . id
8958
9059 # Clean up
9160 pg_tag . destroy
9261 mysql_tag . destroy
93- trilogy_tag . destroy
62+ end
63+ end
64+
65+ if GemTestCase . trilogy_available?
66+ class TrilogySanityCheckTest < GemTestCase
67+ test 'Trilogy database is isolated from PostgreSQL and MySQL' do
68+ # Create tags in all databases
69+ pg_tag = Tag . create! ( name : 'pg-isolation-test' )
70+ mysql_tag = MysqlTag . create! ( name : 'mysql-isolation-test' )
71+ trilogy_tag = TrilogyTag . create! ( name : 'trilogy-isolation-test' )
72+
73+ # Verify Trilogy tag exists only in Trilogy
74+ assert TrilogyTag . exists? ( name : 'trilogy-isolation-test' )
75+ assert_not Tag . exists? ( name : 'trilogy-isolation-test' )
76+ assert_not MysqlTag . exists? ( name : 'trilogy-isolation-test' )
77+
78+ # Verify PostgreSQL tag doesn't exist in Trilogy
79+ assert_not TrilogyTag . exists? ( name : 'pg-isolation-test' )
80+
81+ # Verify MySQL tag doesn't exist in Trilogy
82+ assert_not TrilogyTag . exists? ( name : 'mysql-isolation-test' )
83+
84+ # Clean up
85+ pg_tag . destroy
86+ mysql_tag . destroy
87+ trilogy_tag . destroy
88+ end
89+
90+ test 'Trilogy models use Trilogy adapter' do
91+ assert_equal 'Trilogy' , TrilogyTag . connection . adapter_name
92+ assert_equal 'Trilogy' , TrilogyTagAudit . connection . adapter_name
93+ assert_equal 'Trilogy' , TrilogyLabel . connection . adapter_name
94+ end
95+
96+ test 'can write to all three databases in same test' do
97+ pg_tag = Tag . create! ( name : 'test-pg' )
98+ mysql_tag = MysqlTag . create! ( name : 'test-mysql' )
99+ trilogy_tag = TrilogyTag . create! ( name : 'test-trilogy' )
100+
101+ assert pg_tag . persisted?
102+ assert mysql_tag . persisted?
103+ assert trilogy_tag . persisted?
104+
105+ pg_tag . destroy
106+ mysql_tag . destroy
107+ trilogy_tag . destroy
108+ end
94109 end
95110end
0 commit comments