v0.27.1 packaging update, install and initial config
This commit is contained in:
1 parent
60abc97eb0
commit
4513a9e62b
15 files changed
+431
-110
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
shipped "github.com/lixenwraith/logwisp/config"
|
||||
"github.com/lixenwraith/logwisp/internal/config"
|
||||
"github.com/lixenwraith/logwisp/internal/testutil"
|
||||
"github.com/lixenwraith/logwisp/internal/tlsx"
|
||||
@@ -261,6 +262,35 @@ func TestTLSCommandsIssueAVerifiableChain(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// lw config init writes the shipped configuration to the file lw reads without
|
||||
// -c, or to --out, says how lw finds it, and never replaces a file
|
||||
func TestConfigInitWritesTheShippedFileOnce(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("LOGWISP_CONFIG_FILE", "")
|
||||
t.Setenv("LOGWISP_CONFIG_DIR", "")
|
||||
other := filepath.Join(t.TempDir(), "etc", "logwisp.toml")
|
||||
for _, c := range []struct {
|
||||
args []string
|
||||
hint string
|
||||
}{
|
||||
{[]string{"init"}, "lw reads it without -c"},
|
||||
{[]string{"init", "--out", other}, "lw -c " + other},
|
||||
} {
|
||||
if code, _, stderr := runCommand(t, "config", c.args...); code != 0 || !strings.Contains(stderr, c.hint) {
|
||||
t.Fatalf("lw config %v: exit %d: %s", c.args, code, stderr)
|
||||
}
|
||||
if code, _, stderr := runCommand(t, "config", c.args...); code != 1 || !strings.Contains(stderr, "exists") {
|
||||
t.Fatalf("lw config %v again: exit %d: %s", c.args, code, stderr)
|
||||
}
|
||||
}
|
||||
for _, path := range []string{filepath.Join(home, ".config", "logwisp", "logwisp.toml"), other} {
|
||||
if data, err := os.ReadFile(path); err != nil || !bytes.Equal(data, shipped.Sample) {
|
||||
t.Errorf("%s is not the shipped configuration: %v", path, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var update = flag.Bool("update", false, "rewrite the completion scripts: make completion")
|
||||
|
||||
// The installed completion scripts are what lw's tables generate
|
||||
|
||||
Reference in new issue
Block a user