1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

fix: using t.TempDir (#1289)

This commit is contained in:
Yongzheng Lai 2021-08-02 18:51:31 +08:00 committed by GitHub
parent 5710bf0e30
commit b68265c365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -31,7 +31,7 @@ const _testJSON = `
func TestEnvWithPrefix(t *testing.T) {
var (
path = filepath.Join(os.TempDir(), "test_config")
path = filepath.Join(t.TempDir(), "test_config")
filename = filepath.Join(path, "test.json")
data = []byte(_testJSON)
)
@ -143,7 +143,7 @@ func TestEnvWithPrefix(t *testing.T) {
func TestEnvWithoutPrefix(t *testing.T) {
var (
path = filepath.Join(os.TempDir(), "test_config")
path = filepath.Join(t.TempDir(), "test_config")
filename = filepath.Join(path, "test.json")
data = []byte(_testJSON)
)

View File

@ -84,7 +84,7 @@ const (
func TestFile(t *testing.T) {
var (
path = filepath.Join(os.TempDir(), "test_config")
path = filepath.Join(t.TempDir(), "test_config")
file = filepath.Join(path, "test.json")
data = []byte(_testJSON)
)
@ -178,7 +178,7 @@ func testSource(t *testing.T, path string, data []byte) {
}
func TestConfig(t *testing.T) {
path := filepath.Join(os.TempDir(), "test_config.json")
path := filepath.Join(t.TempDir(), "test_config.json")
defer os.Remove(path)
if err := ioutil.WriteFile(path, []byte(_testJSON), 0666); err != nil {
t.Error(err)
@ -192,7 +192,7 @@ func TestConfig(t *testing.T) {
}
func testConfig(t *testing.T, c config.Config) {
var expected = map[string]interface{}{
expected := map[string]interface{}{
"test.settings.int_key": int64(1000),
"test.settings.float_key": float64(1000.1),
"test.settings.string_key": "string_value",
@ -258,7 +258,6 @@ func testConfig(t *testing.T, c config.Config) {
if _, err := c.Value("not_found_key").Bool(); errors.Is(err, config.ErrNotFound) {
t.Logf("not_found_key not match: %v", err)
}
}
func testScan(t *testing.T, c config.Config) {