1
0
Fork 0
hswro-alarm-bot/main_test.go

19 lines
471 B
Go
Raw Permalink Normal View History

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)
}