metis/pkg/service/settings_test.go

31 lines
991 B
Go

package service
import (
"path/filepath"
"reflect"
"testing"
)
func TestFromEnvIncludesRemotePodTimeout(t *testing.T) {
dataDir := filepath.Join(t.TempDir(), "data")
t.Setenv("METIS_DATA_DIR", dataDir)
t.Setenv("METIS_FLASH_HOSTS", "titan-22, titan-24")
t.Setenv("METIS_REMOTE_POD_TIMEOUT_SEC", "1800")
t.Setenv("METIS_DEFAULT_FLASH_HOST", "titan-22")
t.Setenv("METIS_LOCAL_HOST", "titan-iac")
settings := FromEnv()
if settings.CacheDir != filepath.Join(dataDir, "cache") {
t.Fatalf("expected cache dir under data dir, got %q", settings.CacheDir)
}
if settings.RemotePodTimeout != 1800 {
t.Fatalf("expected RemotePodTimeout=1800, got %d", settings.RemotePodTimeout)
}
if !reflect.DeepEqual(settings.FlashHosts, []string{"titan-22", "titan-24"}) {
t.Fatalf("unexpected flash hosts: %#v", settings.FlashHosts)
}
if settings.DefaultFlashHost != "titan-22" || settings.LocalHost != "titan-iac" {
t.Fatalf("unexpected local/default host settings: %+v", settings)
}
}