github.com/erroneousboat/dot@v0.0.0-20170402193747-d2fd504d98ec/setup_test.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"os"
     7  	"testing"
     8  )
     9  
    10  func TestCreateDotConfigFile(t *testing.T) {
    11  	tempDir, err := ioutil.TempDir("", "")
    12  	if err != nil {
    13  		t.Error(err)
    14  	}
    15  
    16  	pathDotConfig := fmt.Sprintf("%s/.dotconfig", tempDir)
    17  
    18  	// set current working directory to home dir, this will
    19  	// make the GetRelativePathFromCwd work
    20  	os.Chdir(HomeDir())
    21  
    22  	// test creating .dotconfig file
    23  	err = CreateDotConfigFile(pathDotConfig)
    24  	if err != nil {
    25  		t.Error(err)
    26  	}
    27  }
    28  
    29  func TestCreateDotFolders(t *testing.T) {
    30  	// change current working directory
    31  	tempDir, err := ioutil.TempDir("", "")
    32  	if err != nil {
    33  		t.Error(err)
    34  	}
    35  	os.Chdir(tempDir)
    36  
    37  	// create the folders
    38  	err = CreateDotFolders()
    39  	if err != nil {
    40  		t.Error(err)
    41  	}
    42  }