package main import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" ) func TestGetPersistenceFilename(t *testing.T) { var oldStateDir = os.Getenv("STATE_DIRECTORY") os.Setenv("STATE_DIRECTORY", "test_dir") assert.Equal(t, filepath.Join("test_dir", PersistenceFilename), getPersistenceFilePath()) os.Setenv("STATE_DIRECTORY", "") assert.Equal(t, PersistenceFilename, getPersistenceFilePath()) os.Setenv("STATE_DIRECTORY", oldStateDir) }