rename gdebug.TestData* -> gtest.Data*; add UT case for http server

This commit is contained in:
John Guo
2022-03-17 16:58:04 +08:00
parent b3e66d8023
commit bceb5fc7de
34 changed files with 167 additions and 152 deletions

View File

@ -345,11 +345,11 @@ func AssertNil(value interface{}) {
AssertNE(value, nil)
}
// TestDataPath retrieves and returns the testdata path of current package,
// DataPath retrieves and returns the testdata path of current package,
// which is used for unit testing cases only.
// The optional parameter `names` specifies the sub-folders/sub-files,
// which will be joined with current system separator and returned with the path.
func TestDataPath(names ...string) string {
func DataPath(names ...string) string {
_, path, _ := gdebug.CallerWithFilter([]string{pathFilterKey})
path = filepath.Dir(path) + string(filepath.Separator) + "testdata"
for _, name := range names {
@ -358,9 +358,9 @@ func TestDataPath(names ...string) string {
return path
}
// TestDataContent retrieves and returns the file content for specified testdata path of current package
func TestDataContent(names ...string) string {
path := TestDataPath(names...)
// DataContent retrieves and returns the file content for specified testdata path of current package
func DataContent(names ...string) string {
path := DataPath(names...)
if path != "" {
data, err := ioutil.ReadFile(path)
if err == nil {