forked from easegress-io/easegress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add more test * add more test * add more test for filters and register * when meshcontroller is ready, then update their tests * add more tests * add more tests * add more tests * add more tests * add more tests * add more tests * add more tests
- Loading branch information
1 parent
21f959c
commit 6cbfa18
Showing
25 changed files
with
949 additions
and
34 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
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,56 @@ | ||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package httpbuilder | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestToFloat64(t *testing.T) { | ||
assert := assert.New(t) | ||
assert.Equal(float64(1), toFloat64(int8(1))) | ||
assert.Equal(float64(1), toFloat64(int16(1))) | ||
assert.Equal(float64(1), toFloat64(int32(1))) | ||
assert.Equal(float64(1), toFloat64(int64(1))) | ||
assert.Equal(float64(1), toFloat64(int(1))) | ||
assert.Equal(float64(1), toFloat64(uint8(1))) | ||
assert.Equal(float64(1), toFloat64(uint16(1))) | ||
assert.Equal(float64(1), toFloat64(uint32(1))) | ||
assert.Equal(float64(1), toFloat64(uint64(1))) | ||
assert.Equal(float64(1), toFloat64(uint(1))) | ||
assert.Equal(float64(1), toFloat64(uintptr(1))) | ||
assert.Equal(float64(1), toFloat64("1")) | ||
assert.Panics(func() { toFloat64("s") }) | ||
assert.Panics(func() { toFloat64(func() {}) }) | ||
} | ||
|
||
func TestExtraFuncs(t *testing.T) { | ||
assert := assert.New(t) | ||
assert.Equal(float64(123), extraFuncs["addf"].(func(a, b interface{}) float64)(120, 3)) | ||
assert.Equal(float64(117), extraFuncs["subf"].(func(a, b interface{}) float64)(120, 3)) | ||
assert.Equal(float64(360), extraFuncs["mulf"].(func(a, b interface{}) float64)(120, 3)) | ||
assert.Equal(float64(40), extraFuncs["divf"].(func(a, b interface{}) float64)(120, 3)) | ||
assert.Panics(func() { extraFuncs["divf"].(func(a, b interface{}) float64)(120, 0) }) | ||
|
||
assert.Equal("", extraFuncs["log"].(func(level, msg string) string)("debug", "debug")) | ||
assert.Equal("", extraFuncs["log"].(func(level, msg string) string)("info", "info")) | ||
assert.Equal("", extraFuncs["log"].(func(level, msg string) string)("warn", "warn")) | ||
assert.Equal("", extraFuncs["log"].(func(level, msg string) string)("error", "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
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,57 @@ | ||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package httpbuilder | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBuilderResponseBody(t *testing.T) { | ||
assert := assert.New(t) | ||
r := &response{ | ||
Response: nil, | ||
rawBody: []byte("abc"), | ||
} | ||
assert.Equal([]byte("abc"), r.RawBody()) | ||
assert.Equal("abc", r.Body()) | ||
_, err := r.JSONBody() | ||
assert.NotNil(err) | ||
|
||
r = &response{ | ||
Response: nil, | ||
rawBody: []byte("123"), | ||
} | ||
_, err = r.JSONBody() | ||
assert.Nil(err) | ||
|
||
r = &response{ | ||
Response: nil, | ||
rawBody: []byte("{{{{{}"), | ||
} | ||
_, err = r.YAMLBody() | ||
assert.NotNil(err) | ||
|
||
r = &response{ | ||
Response: nil, | ||
rawBody: []byte("123"), | ||
} | ||
_, err = r.YAMLBody() | ||
assert.Nil(err) | ||
} |
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
Oops, something went wrong.