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:
parent
5710bf0e30
commit
b68265c365
4
config/env/env_test.go
vendored
4
config/env/env_test.go
vendored
@ -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)
|
||||
)
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user