github.com/0xsequence/ethkit@v1.25.0/util/testing.go (about)

     1  package util
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"os"
     7  )
     8  
     9  func ReadTestConfig(testConfigFile string) (map[string]string, error) {
    10  	config := map[string]string{}
    11  
    12  	_, err := os.Stat(testConfigFile)
    13  	if err != nil {
    14  		return config, nil
    15  	}
    16  
    17  	data, err := os.ReadFile(testConfigFile)
    18  	if err != nil {
    19  		return nil, fmt.Errorf("%s file could not be read", testConfigFile)
    20  	}
    21  
    22  	err = json.Unmarshal(data, &config)
    23  	if err != nil {
    24  		return nil, fmt.Errorf("%s file json parsing error", testConfigFile)
    25  	}
    26  
    27  	return config, nil
    28  }