Skip to content

Commit

Permalink
fix relative URL error in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samjsong committed Sep 3, 2020
1 parent 6214b48 commit e0c3bf4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class EnhanceK8sMetadataFilterTest < Test::Unit::TestCase
end

test 'create driver' do
conf = %([])
conf = %{
kubernetes_url http://localhost:8080
}
create_driver(conf)
end

Expand Down
35 changes: 18 additions & 17 deletions fluent-plugin-events/test/plugin/test_in_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def create_driver(conf)
driver = Fluent::Test::Driver::Input.new(Fluent::Plugin::EventsInput).configure(conf)
end

def configure_test_driver(config = %([]))
def configure_test_driver(config = %{})
config += %{kubernetes_url http://localhost:8080}
driver = create_driver(config).instance
connect_kubernetes_with_api_version(driver)
driver.instance_variable_set(:@clients, @clients)
Expand All @@ -45,9 +46,9 @@ def connect_kubernetes_with_api_version(driver)
end

test 'pull_resource_version correctly from eventlist with v1beta1 api version' do
config = %([
config = %{
api_version "events.k8s.io/v1beta1"
])
}
driver = configure_test_driver(config)
mock_get_events('api_list_events_v1beta1.json')

Expand All @@ -66,9 +67,9 @@ def connect_kubernetes_with_api_version(driver)
end

test 'initialize_resource_version correctly for different client' do
config = %([
config = %{
api_version "events.k8s.io/v1beta1"
])
}
driver = configure_test_driver(config)
mock_get_config_map

Expand All @@ -93,9 +94,9 @@ def connect_kubernetes_with_api_version(driver)


test 'watch_events with customer defined type_selector' do
config = %([
config = %{
type_selector ["ADDED", "MODIFIED", "DELETED"]
])
}
driver = configure_test_driver(config)
mock_watch_events('api_watch_events_v1.txt')

Expand All @@ -110,28 +111,28 @@ def connect_kubernetes_with_api_version(driver)

test 'configuration error will be thrown if type_selector is invalid' do
assert_raise Fluent::ConfigError do
create_driver(%([
create_driver(%{
type_selector ["ADDED", "MODIFIED", "DELETED", "BOOKED"]
]))
})
end

assert_raise Fluent::ConfigError do
create_driver(%([
create_driver(%{
type_selector ["ADDED", "MODIFIED", "INVALIDTYPE"]
]))
})
end

assert_raise Fluent::ConfigError do
create_driver(%([
create_driver(%{
type_selector []
]))
})
end
end

test 'watch other resources with default type_selector' do
config = %([
config = %{
resource_name "services"
])
}
driver = configure_test_driver(config)
mock_watch_services

Expand All @@ -145,9 +146,9 @@ def connect_kubernetes_with_api_version(driver)
end

test 'watch events correctly with v1beta1 api version' do
config = %([
config = %{
api_version "events.k8s.io/v1beta1"
])
}
driver = configure_test_driver(config)
mock_watch_events('api_watch_events_v1beta1.txt')

Expand Down

0 comments on commit e0c3bf4

Please sign in to comment.