~gpanders/ijq

77f333e2316c9ac07fadf22c56e87b641ad5860a — Herby Gillot 21 days ago c3d60ef
Test creating history file in sub-directory
1 files changed, 15 insertions(+), 0 deletions(-)

M history_test.go
M history_test.go => history_test.go +15 -0
@@ 4,6 4,7 @@ import (
	"io/ioutil"
	"math/rand"
	"os"
	"path"
	"strconv"
	"testing"
	"time"


@@ 91,6 92,20 @@ func TestHistoryAddRepeating(t *testing.T) {
	assert.NoError(t, os.Remove(histFile))
}

func TestHistoryWithinSubDir(t *testing.T) {
	rootDir := "./testdata/myroot"

	histFile := path.Join(rootDir, "myhistory")

	h := &history{Path: histFile}

	err := h.Add("one")
	assert.NoError(t, err)
	assert.FileExists(t, histFile)

	assert.NoError(t, os.RemoveAll(rootDir))
}

func TestHistoryGetMissingFile(t *testing.T) {
	historyFile := "./this.does.not.exist"