@@ -16,6 +16,39 @@ module ForestAdminDatasourceRpc
1616
1717 include_examples 'with introspection'
1818
19+ context 'with unknown options' do
20+ let ( :schema_polling_client ) { instance_double ( Utils ::SchemaPollingClient , start? : true , stop : nil , current_schema : introspection ) }
21+ let ( :logger ) { ForestAdminAgent ::Facades ::Container . logger }
22+
23+ before do
24+ allow ( Utils ::SchemaPollingClient ) . to receive ( :new ) . and_return ( schema_polling_client )
25+ end
26+
27+ it 'logs a warning when unknown keys are passed' do
28+ described_class . build ( { uri : 'http://localhost' , url : 'http://localhost' , foo : 'bar' } )
29+
30+ expect ( logger ) . to have_received ( :log ) . with (
31+ 'Warn' ,
32+ a_string_matching ( /Unknown option.*\b url\b .*\b foo\b / )
33+ )
34+ end
35+
36+ it 'logs a warning when a key does not exist in known options' do
37+ described_class . build ( { uri : 'http://localhost' , url : 'http://localhost' } )
38+
39+ expect ( logger ) . to have_received ( :log ) . with (
40+ 'Warn' ,
41+ a_string_matching ( /Unknown option.*url.*Known options are/ )
42+ )
43+ end
44+
45+ it 'does not log a warning when only known keys are passed' do
46+ described_class . build ( { uri : 'http://localhost' , auth_secret : 'secret' , schema_polling_interval_sec : 60 } )
47+
48+ expect ( logger ) . not_to have_received ( :log ) . with ( 'Warn' , anything )
49+ end
50+ end
51+
1952 context 'when server is running' do
2053 let ( :schema_polling_client ) { instance_double ( Utils ::SchemaPollingClient , start? : true , stop : nil , current_schema : introspection ) }
2154 let ( :response ) { Utils ::SchemaResponse . new ( introspection , 'etag123' ) }
0 commit comments