This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added more tests according to testplan
- Loading branch information
Showing
20 changed files
with
753 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var path = require("path"); | ||
|
||
// the test-modules are not in the standard paths | ||
// | ||
// the first one should be local_modules/ | ||
// test_modules/ is just right next to it | ||
module.paths.push(path.join(module.paths[0], "..", "test_modules")); | ||
|
||
require("test-require-nesting-1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var path = require("path"); | ||
|
||
// the test-modules are not in the standard paths | ||
// | ||
// the first one should be local_modules/ | ||
// test_modules/ is just right next to it | ||
module.paths.push(path.join(module.paths[0], "..", "test_modules")); | ||
|
||
var m_direct = require("test-require-direct"); | ||
var m_dir_with_indexjs = require("test-require-dir-with-indexjs"); | ||
var m_dir_with_packagejson = require("test-require-dir-with-packagejson"); | ||
// 'require' the same module again. It shouldn't trigger a reload nor reset the counter | ||
var m_no_reload = require("test-require-direct"); | ||
|
||
({ | ||
stmts: function(stmt) { | ||
// all results share the same column-def | ||
var columns = { | ||
columns: [ | ||
{ | ||
name: "me", | ||
type: "STRING" | ||
} | ||
] | ||
}; | ||
|
||
if (stmt === "direct") { | ||
return { | ||
result: Object.assign({ | ||
rows: [ | ||
[ m_direct.me ] | ||
] | ||
}, columns) | ||
} | ||
} else if (stmt === "dir-with-indexjs") { | ||
return { | ||
result: Object.assign({ | ||
rows: [ | ||
[ m_dir_with_indexjs.me ] | ||
] | ||
}, columns) | ||
} | ||
} else if (stmt === "dir-with-packagejson") { | ||
return { | ||
result: Object.assign({ | ||
rows: [ | ||
[ m_dir_with_packagejson.me ] | ||
] | ||
}, columns) | ||
} | ||
} else if (stmt === "no-reload-0") { | ||
return { | ||
result: Object.assign({ | ||
rows: [ | ||
[ m_direct.counter().toString() ] | ||
] | ||
}, columns) | ||
} | ||
} else if (stmt === "no-reload-1") { | ||
return { | ||
result: Object.assign({ | ||
rows: [ | ||
[ m_no_reload.counter().toString() ] | ||
] | ||
}, columns) | ||
} | ||
} else { | ||
return { | ||
error: { | ||
code: 1164, | ||
message: "don't know about " + stmt | ||
} | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// ensure that 'stmts.result.columns[].decimal = Infinity' throws | ||
|
||
({ | ||
stmts: [ | ||
{ | ||
result: { | ||
columns: [ | ||
{ | ||
name: "foo", | ||
type: "STRING", | ||
decimals: Infinity | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// ensure that 'stmts.result.columns[].repeat' throws | ||
|
||
({ | ||
stmts: [ | ||
{ | ||
result: { | ||
columns: [ | ||
{ | ||
name: "foo", | ||
type: "STRING", | ||
repeat: 25 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}) |
1 change: 1 addition & 0 deletions
1
tests/component/data/test_modules/test-require-dir-with-indexjs/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.me = "dir-with-index.js"; |
1 change: 1 addition & 0 deletions
1
tests/component/data/test_modules/test-require-dir-with-packagejson/foo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.me = "dir-with-package.json"; |
3 changes: 3 additions & 0 deletions
3
tests/component/data/test_modules/test-require-dir-with-packagejson/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"main": "foo.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var c = 0; | ||
|
||
exports.me = "direct"; | ||
exports.counter = function() { | ||
return c++; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("test-require-nesting-2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("test-require-nesting-3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("test-require-nesting-4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("test-require-nesting-5") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// a parse-error | ||
|
||
[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License, version 2.0, | ||
as published by the Free Software Foundation. | ||
This program is also distributed with certain software (including | ||
but not limited to OpenSSL) that is licensed under separate terms, | ||
as designated in a particular file or component or in included license | ||
documentation. The authors of MySQL hereby grant you an additional | ||
permission to link the program and your derivative works with the | ||
separately licensed software that they have included with MySQL. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifdef _WIN32 | ||
// ensure windows.h doesn't expose min() nor max() | ||
# define NOMINMAX | ||
#endif | ||
|
||
#include <thread> | ||
|
||
#include "gmock/gmock.h" | ||
#include "router_component_test.h" | ||
|
||
Path g_origin_path; | ||
|
||
|
||
|
||
class MockServerCLITest : public RouterComponentTest, public ::testing::Test { | ||
protected: | ||
void SetUp() override { | ||
set_origin(g_origin_path); | ||
RouterComponentTest::SetUp(); | ||
} | ||
}; | ||
|
||
/** | ||
* ensure mock-server supports --version. | ||
* | ||
* verifies: | ||
* | ||
* - WL12118 | ||
* - TS_1-3 | ||
*/ | ||
TEST_F(MockServerCLITest, has_version) { | ||
auto mysql_server_mock_path = get_mysqlserver_mock_exec().str(); | ||
|
||
ASSERT_THAT(mysql_server_mock_path, ::testing::StrNe("")); | ||
|
||
SCOPED_TRACE("// start binary"); | ||
auto cmd = launch_command(mysql_server_mock_path, | ||
std::vector<std::string>{"--version"}, | ||
true); | ||
|
||
SCOPED_TRACE("// wait for exit"); | ||
EXPECT_EQ(cmd.wait_for_exit(1000), 0); // should be quick, and return 0 | ||
SCOPED_TRACE("// checking stdout"); | ||
EXPECT_THAT(cmd.get_full_output(), ::testing::ContainsRegex("[0-9]\\.[0-9]\\.[0-9]")); | ||
} | ||
|
||
/** | ||
* ensure mock-server supports --help. | ||
*/ | ||
TEST_F(MockServerCLITest, has_help) { | ||
auto mysql_server_mock_path = get_mysqlserver_mock_exec().str(); | ||
|
||
ASSERT_THAT(mysql_server_mock_path, ::testing::StrNe("")); | ||
|
||
SCOPED_TRACE("// start binary with --help"); | ||
auto cmd = launch_command(mysql_server_mock_path, | ||
std::vector<std::string>{"--help"}, | ||
true); | ||
|
||
SCOPED_TRACE("// wait for exit"); | ||
EXPECT_NO_THROW(EXPECT_EQ(cmd.wait_for_exit(1000), 0)); // should be quick, and return 0 | ||
SCOPED_TRACE("// checking stdout contains --version"); | ||
EXPECT_THAT(cmd.get_full_output(), ::testing::HasSubstr("--version")); | ||
} | ||
|
||
/** | ||
* ensure mock-server supports --http-port=65536 fails. | ||
* | ||
* verifies: | ||
* | ||
* - WL12118 | ||
* - TS_1-4 | ||
*/ | ||
TEST_F(MockServerCLITest, http_port_too_large) { | ||
auto mysql_server_mock_path = get_mysqlserver_mock_exec().str(); | ||
|
||
ASSERT_THAT(mysql_server_mock_path, ::testing::StrNe("")); | ||
|
||
SCOPED_TRACE("// start binary with --http-port=65536"); | ||
auto cmd = launch_command(mysql_server_mock_path, | ||
std::vector<std::string>{"--http-port=65536"}, | ||
true); | ||
|
||
SCOPED_TRACE("// wait for exit"); | ||
EXPECT_NO_THROW(EXPECT_NE(cmd.wait_for_exit(1000), 0)); // should be quick, and return failure (255) | ||
SCOPED_TRACE("// checking stdout contains errormsg"); | ||
EXPECT_THAT(cmd.get_full_output(), ::testing::HasSubstr("was '65536'")); | ||
} | ||
|
||
|
||
int main(int argc, char *argv[]) { | ||
g_origin_path = Path(argv[0]).dirname(); | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
Oops, something went wrong.