Skip to content

Commit e42ec9f

Browse files
committed
βœ…πŸšš Rename/reorganize test files
The `test/net/imap/test_imap_*` files are all client integration tests that create a fake server socket and connect to it, testing a method or a cluster of methods on `Net::IMAP`. All other test files are for unit tests for a specific class or module.
1 parent cd154d8 commit e42ec9f

File tree

6 files changed

+81
-75
lines changed

6 files changed

+81
-75
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "net/imap"
44
require "test/unit"
55

6-
class IMAPAuthenticatorsTest < Test::Unit::TestCase
6+
class AuthenticatorsTest < Test::Unit::TestCase
77

88
test "SASL::Authenticators.normalize_name" do
99
authenticators = Net::IMAP::SASL::Authenticators
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# frozen_string_literal: true
2+
3+
require "net/imap"
4+
require "test/unit"
5+
6+
class ConnectionStateTest < Test::Unit::TestCase
7+
NotAuthenticated = Net::IMAP::ConnectionState::NotAuthenticated
8+
Authenticated = Net::IMAP::ConnectionState::Authenticated
9+
Selected = Net::IMAP::ConnectionState::Selected
10+
Logout = Net::IMAP::ConnectionState::Logout
11+
12+
test "#name" do
13+
assert_equal "not_authenticated", NotAuthenticated[].name
14+
assert_equal "authenticated", Authenticated[] .name
15+
assert_equal "selected", Selected[] .name
16+
assert_equal "logout", Logout[] .name
17+
end
18+
19+
20+
test "#to_sym" do
21+
assert_equal :not_authenticated, NotAuthenticated[].to_sym
22+
assert_equal :authenticated, Authenticated[] .to_sym
23+
assert_equal :selected, Selected[] .to_sym
24+
assert_equal :logout, Logout[] .to_sym
25+
end
26+
27+
test "#deconstruct" do
28+
assert_equal [:not_authenticated], NotAuthenticated[].deconstruct
29+
assert_equal [:authenticated], Authenticated[] .deconstruct
30+
assert_equal [:selected], Selected[] .deconstruct
31+
assert_equal [:logout], Logout[] .deconstruct
32+
end
33+
34+
test "#deconstruct_keys" do
35+
assert_equal({symbol: :not_authenticated}, NotAuthenticated[].deconstruct_keys([:symbol]))
36+
assert_equal({symbol: :authenticated}, Authenticated[] .deconstruct_keys([:symbol]))
37+
assert_equal({symbol: :selected}, Selected[] .deconstruct_keys([:symbol]))
38+
assert_equal({symbol: :logout}, Logout[] .deconstruct_keys([:symbol]))
39+
assert_equal({name: "not_authenticated"}, NotAuthenticated[].deconstruct_keys([:name]))
40+
assert_equal({name: "authenticated"}, Authenticated[] .deconstruct_keys([:name]))
41+
assert_equal({name: "selected"}, Selected[] .deconstruct_keys([:name]))
42+
assert_equal({name: "logout"}, Logout[] .deconstruct_keys([:name]))
43+
end
44+
45+
test "#not_authenticated?" do
46+
assert_equal true, NotAuthenticated[].not_authenticated?
47+
assert_equal false, Authenticated[] .not_authenticated?
48+
assert_equal false, Selected[] .not_authenticated?
49+
assert_equal false, Logout[] .not_authenticated?
50+
end
51+
52+
test "#authenticated?" do
53+
assert_equal false, NotAuthenticated[].authenticated?
54+
assert_equal true, Authenticated[] .authenticated?
55+
assert_equal false, Selected[] .authenticated?
56+
assert_equal false, Logout[] .authenticated?
57+
end
58+
59+
test "#selected?" do
60+
assert_equal false, NotAuthenticated[].selected?
61+
assert_equal false, Authenticated[] .selected?
62+
assert_equal true, Selected[] .selected?
63+
assert_equal false, Logout[] .selected?
64+
end
65+
66+
test "#logout?" do
67+
assert_equal false, NotAuthenticated[].logout?
68+
assert_equal false, Authenticated[] .logout?
69+
assert_equal false, Selected[] .logout?
70+
assert_equal true, Logout[] .logout?
71+
end
72+
73+
end
74+
75+

β€Žtest/net/imap/test_imap_connection_state.rbβ€Ž

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,75 +4,6 @@
44
require "test/unit"
55
require_relative "fake_server"
66

7-
class ConnectionStateTest < Test::Unit::TestCase
8-
NotAuthenticated = Net::IMAP::ConnectionState::NotAuthenticated
9-
Authenticated = Net::IMAP::ConnectionState::Authenticated
10-
Selected = Net::IMAP::ConnectionState::Selected
11-
Logout = Net::IMAP::ConnectionState::Logout
12-
13-
test "#name" do
14-
assert_equal "not_authenticated", NotAuthenticated[].name
15-
assert_equal "authenticated", Authenticated[] .name
16-
assert_equal "selected", Selected[] .name
17-
assert_equal "logout", Logout[] .name
18-
end
19-
20-
21-
test "#to_sym" do
22-
assert_equal :not_authenticated, NotAuthenticated[].to_sym
23-
assert_equal :authenticated, Authenticated[] .to_sym
24-
assert_equal :selected, Selected[] .to_sym
25-
assert_equal :logout, Logout[] .to_sym
26-
end
27-
28-
test "#deconstruct" do
29-
assert_equal [:not_authenticated], NotAuthenticated[].deconstruct
30-
assert_equal [:authenticated], Authenticated[] .deconstruct
31-
assert_equal [:selected], Selected[] .deconstruct
32-
assert_equal [:logout], Logout[] .deconstruct
33-
end
34-
35-
test "#deconstruct_keys" do
36-
assert_equal({symbol: :not_authenticated}, NotAuthenticated[].deconstruct_keys([:symbol]))
37-
assert_equal({symbol: :authenticated}, Authenticated[] .deconstruct_keys([:symbol]))
38-
assert_equal({symbol: :selected}, Selected[] .deconstruct_keys([:symbol]))
39-
assert_equal({symbol: :logout}, Logout[] .deconstruct_keys([:symbol]))
40-
assert_equal({name: "not_authenticated"}, NotAuthenticated[].deconstruct_keys([:name]))
41-
assert_equal({name: "authenticated"}, Authenticated[] .deconstruct_keys([:name]))
42-
assert_equal({name: "selected"}, Selected[] .deconstruct_keys([:name]))
43-
assert_equal({name: "logout"}, Logout[] .deconstruct_keys([:name]))
44-
end
45-
46-
test "#not_authenticated?" do
47-
assert_equal true, NotAuthenticated[].not_authenticated?
48-
assert_equal false, Authenticated[] .not_authenticated?
49-
assert_equal false, Selected[] .not_authenticated?
50-
assert_equal false, Logout[] .not_authenticated?
51-
end
52-
53-
test "#authenticated?" do
54-
assert_equal false, NotAuthenticated[].authenticated?
55-
assert_equal true, Authenticated[] .authenticated?
56-
assert_equal false, Selected[] .authenticated?
57-
assert_equal false, Logout[] .authenticated?
58-
end
59-
60-
test "#selected?" do
61-
assert_equal false, NotAuthenticated[].selected?
62-
assert_equal false, Authenticated[] .selected?
63-
assert_equal true, Selected[] .selected?
64-
assert_equal false, Logout[] .selected?
65-
end
66-
67-
test "#logout?" do
68-
assert_equal false, NotAuthenticated[].logout?
69-
assert_equal false, Authenticated[] .logout?
70-
assert_equal false, Selected[] .logout?
71-
assert_equal true, Logout[] .logout?
72-
end
73-
74-
end
75-
767
class IMAPConnectionStateTest < Test::Unit::TestCase
778
include Net::IMAP::FakeServer::TestHelper
789

β€Žtest/net/imap/test_imap_data_encoding.rbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "net/imap"
44
require "test/unit"
55

6-
class IMAPDataEncodingTest < Test::Unit::TestCase
6+
class DataEncodingTest < Test::Unit::TestCase
77

88
def test_encode_utf7
99
assert_equal("foo", Net::IMAP.encode_utf7("foo"))

test/net/imap/test_deprecated_client_options.rb renamed to test/net/imap/test_imap_deprecated_client_options.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require "test/unit"
55
require_relative "fake_server"
66

7-
class DeprecatedClientOptionsTest < Test::Unit::TestCase
7+
class IMAPDeprecatedClientOptionsTest < Test::Unit::TestCase
88
include Net::IMAP::FakeServer::TestHelper
99

1010
def setup
@@ -20,7 +20,7 @@ def teardown
2020
Socket.do_not_reverse_lookup = @do_not_reverse_lookup
2121
end
2222

23-
class InitializeTests < DeprecatedClientOptionsTest
23+
class InitializeTests < IMAPDeprecatedClientOptionsTest
2424

2525
test "Convert obsolete options hash to keywords" do
2626
run_fake_server_in_thread do |server|
@@ -100,7 +100,7 @@ class InitializeTests < DeprecatedClientOptionsTest
100100

101101
end
102102

103-
class StartTLSTests < DeprecatedClientOptionsTest
103+
class StartTLSTests < IMAPDeprecatedClientOptionsTest
104104
test "Convert obsolete options hash to keywords" do
105105
with_fake_server(preauth: false) do |server, imap|
106106
imap.starttls(ca_file: server.config.tls[:ca_file], min_version: :TLS1_2)

test/net/imap/test_imap_response_parser.rb renamed to test/net/imap/test_response_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require "test/unit"
55
require_relative "net_imap_test_helpers"
66

7-
class IMAPResponseParserTest < Test::Unit::TestCase
7+
class ResponseParserTest < Test::Unit::TestCase
88
TEST_FIXTURE_PATH = File.join(__dir__, "fixtures/response_parser")
99

1010
include NetIMAPTestHelpers

0 commit comments

Comments
Β (0)