fix: using t.TempDir (#1289)

pull/1293/head
Yongzheng Lai 3 years ago committed by GitHub
parent 5710bf0e30
commit b68265c365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      config/env/env_test.go
  2. 7
      config/file/file_test.go

@ -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…
Cancel
Save