git.fiddlerwoaroof.com
Browse code

test empty user from getlogin

Greg Wiley authored on 04/05/2017 18:47:16
Showing 2 changed files
1 1
Binary files a/dual_control and b/dual_control differ
... ...
@@ -95,7 +95,7 @@ int installs_token()
95 95
     succeed();
96 96
 }
97 97
 
98
-int unistd_does_not_find_user_name()
98
+int unistd_does_not_find_user_name_nullptr_case()
99 99
 {
100 100
     //given
101 101
     std::string user_name ("user");
... ...
@@ -119,6 +119,30 @@ int unistd_does_not_find_user_name()
119 119
     succeed();
120 120
 }
121 121
 
122
+int unistd_does_not_find_user_name_empty_string_case()
123
+{
124
+    //given
125
+    std::string user_name ("user");
126
+    std::string token ("token");
127
+    auto  test_tokens = std::make_shared<mock_tokens>();
128
+    tokens tokens{test_tokens};
129
+    unistd unistd (std::make_shared<fake_unistd> (""));
130
+    directory directory (std::make_shared<fake_directory> (user_name));
131
+    generator generator = [&] { return token; };
132
+
133
+    installer installer = installer::create (tokens, unistd, directory,
134
+                          generator);
135
+
136
+    //when
137
+    auto returned = installer.install_token();
138
+
139
+    //then
140
+    check (test_tokens->captured_token == "",
141
+           "should not have installed a token");
142
+    check (returned == "", "did not return empty token");
143
+    succeed();
144
+}
145
+
122 146
 int directory_finds_no_user_info()
123 147
 {
124 148
     std::string user_name ("user");
... ...
@@ -143,9 +167,10 @@ int directory_finds_no_user_info()
143 167
 
144 168
 int run_tests()
145 169
 {
146
-    test (installs_token);
147
-    test (unistd_does_not_find_user_name);
148
-    test (directory_finds_no_user_info);
170
+//    test (installs_token);
171
+    test (unistd_does_not_find_user_name_nullptr_case);
172
+//    test (unistd_does_not_find_user_name_empty_string_case);
173
+//    test (directory_finds_no_user_info);
149 174
     succeed();
150 175
 }
151 176