scout 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/scout'
3
+ require "logger"
4
+
5
+ class ScoutTest < Test::Unit::TestCase
6
+
7
+ SCOUT_TEST_SERVER = "http://localhost:4000/"
8
+ SCOUT_TEST_VALID_CLIENT_KEY = "valid key goes here"
9
+ SCOUT_TEST_VALID_PLUGIN_ID = "valid plugin id goes here"
10
+
11
+ def setup
12
+ @log = Logger.new('test.log')
13
+ @scout_server = create_scout_server(SCOUT_TEST_SERVER,
14
+ SCOUT_TEST_VALID_CLIENT_KEY)
15
+ end
16
+
17
+ def teardown
18
+ File.delete('test.log')
19
+ end
20
+
21
+ def test_create
22
+ assert @scout_server
23
+ end
24
+
25
+ def test_should_initialize_new_server
26
+ ["@history_file", "@client_key", "@logger", "@server", "@history"].each do |var|
27
+ assert @scout_server.instance_variables.include?(var)
28
+ end
29
+ end
30
+
31
+ def test_should_send_report
32
+ report = {:server_load => "99.99"}
33
+ assert_does_not_exit { @scout_server.send_report(report, SCOUT_TEST_VALID_PLUGIN_ID) }
34
+ assert_log_contains("Report sent")
35
+ end
36
+
37
+ def test_should_not_send_report_with_invalid_client_key
38
+ @scout_server_invalid_client_key = create_scout_server(SCOUT_TEST_SERVER,
39
+ "1111-2222-3333-4444-5555")
40
+ report = {:server_load => "99.99"}
41
+ assert_does_exit { @scout_server_invalid_client_key.send_report(report, SCOUT_TEST_VALID_PLUGIN_ID) }
42
+ assert_log_contains("Unable to send report to server")
43
+ assert_log_contains("An HTTP error occurred: exit")
44
+ end
45
+
46
+ def test_should_not_send_report_with_invalid_plugin_id
47
+ report = {:server_load => "99.99"}
48
+ assert_does_exit { @scout_server.send_report(report, 9999999999) }
49
+ assert_log_contains("Unable to send report to server")
50
+ assert_log_contains("An HTTP error occurred: exit")
51
+ end
52
+
53
+ def test_should_not_send_report_with_plugin_not_belonging_to_client
54
+ report = {:server_load => "99.99"}
55
+ assert_does_exit { @scout_server.send_report(report, 4) }
56
+ assert_log_contains("Unable to send report to server")
57
+ assert_log_contains("An HTTP error occurred: exit")
58
+ end
59
+
60
+ def create_scout_server(server, client_key, history=File.join("/tmp", "client_history.yaml"), logger=@log)
61
+ Scout::Server.new(server, client_key, history, logger)
62
+ end
63
+
64
+ def assert_log_contains(pattern)
65
+ @log_file = File.read('test.log')
66
+ assert @log_file.include?(pattern), "log does not include the pattern:\n#{pattern}\nlog contains:\n#{@log_file}"
67
+ end
68
+
69
+ # asserts that the program actually exits, terminating.
70
+ def assert_does_exit(&block)
71
+ begin
72
+ yield
73
+ rescue SystemExit
74
+ assert true, "Expected program to not exit, but program did exit."
75
+ return
76
+ end
77
+ flunk "Expected program to exit, but program did not exit."
78
+ end
79
+
80
+ # asserts that the program does not exit.
81
+ def assert_does_not_exit(&block)
82
+ begin
83
+ yield
84
+ rescue SystemExit
85
+ flunk "Expected program to not exit, but program did exit."
86
+ return
87
+ end
88
+ assert true, "Expected program to not exit, but program did exit."
89
+ end
90
+
91
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scout
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Highgroove Studios
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-03-13 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: elif
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: Scout makes monitoring and reporting on your web applications as flexible and simple as possible. Scout is a product of Highgroove Studios.
25
+ email: scout@highgroove.com
26
+ executables:
27
+ - scout
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - AUTHORS
32
+ - COPYING
33
+ - README
34
+ - INSTALL
35
+ - TODO
36
+ - CHANGELOG
37
+ - LICENSE
38
+ files:
39
+ - lib/scout/plugin.rb
40
+ - lib/scout/server.rb
41
+ - lib/scout.rb
42
+ - test/scout_test.rb
43
+ - Rakefile
44
+ - setup.rb
45
+ - AUTHORS
46
+ - COPYING
47
+ - README
48
+ - INSTALL
49
+ - TODO
50
+ - CHANGELOG
51
+ - LICENSE
52
+ has_rdoc: true
53
+ homepage: http://scoutapp.com
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --title
57
+ - Scout Client Documentation
58
+ - --main
59
+ - README
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project: scout
77
+ rubygems_version: 1.0.1
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: Scout makes monitoring and reporting on your web applications as flexible and simple as possible.
81
+ test_files: []
82
+