25 lines
683 B
Go
25 lines
683 B
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"node-lookup/internal/puppet"
|
|
)
|
|
|
|
func TestExecute_MissingConfigNamesBothKeys(t *testing.T) {
|
|
dir := t.TempDir()
|
|
t.Setenv("XDG_CONFIG_HOME", dir)
|
|
t.Setenv("NODE_LOOKUP_URL", "")
|
|
t.Setenv("NODE_LOOKUP_PUPPETBOARD_URL", "")
|
|
old := puppet.SystemConfigPath
|
|
puppet.SystemConfigPath = filepath.Join(dir, "etc-config.yaml")
|
|
t.Cleanup(func() { puppet.SystemConfigPath = old })
|
|
|
|
err := execute([]string{"host1"})
|
|
if err == nil || !strings.Contains(err.Error(), "puppetdb_url") || !strings.Contains(err.Error(), "puppetboard_url") {
|
|
t.Fatalf("expected missing puppetdb_url and puppetboard_url error, got %v", err)
|
|
}
|
|
}
|