added base abstraction functions
This commit is contained in:
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config/generate"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
@@ -14,14 +15,14 @@ func TestConfigInit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetDefaults(t *testing.T) {
|
||||
err := SetDefaults()
|
||||
err := generate.SetDefaults("")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCurrentPath(t *testing.T) {
|
||||
path, err := GetCurrentPath()
|
||||
path, err := generate.GetCurrentPath()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Error(err)
|
||||
@@ -30,7 +31,7 @@ func TestGetCurrentPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPathP2PRC(t *testing.T) {
|
||||
path, err := GetPathP2PRC()
|
||||
path, err := GetPathP2PRC("")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Error(err)
|
||||
@@ -54,7 +55,7 @@ func TestSetEnvName(t *testing.T) {
|
||||
}
|
||||
|
||||
// Checks if the output for the default read is "lol"
|
||||
path, err := GetPathP2PRC()
|
||||
path, err := GetPathP2PRC("")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Error(err)
|
||||
|
||||
@@ -37,7 +37,7 @@ func GetCurrentPath() (string, error) {
|
||||
|
||||
// SetDefaults This function to be called only during a
|
||||
// make install
|
||||
func SetDefaults(envName string) error {
|
||||
func SetDefaults(envName string, forceDefault bool) error {
|
||||
//Setting current directory to default path
|
||||
defaultPath, err := GetCurrentPath()
|
||||
if err != nil {
|
||||
@@ -93,7 +93,7 @@ func SetDefaults(envName string) error {
|
||||
//Paths to search for config file
|
||||
configPaths = append(configPaths, defaultPath)
|
||||
|
||||
if fileExists(defaultPath + "config.json") {
|
||||
if fileExists(defaultPath+"config.json") && forceDefault {
|
||||
err := os.Remove(defaultPath + "config.json")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user