feat(Envs): unifies overrides to PDA_DATA and PDA_CONFIG, and sets them to /tmp/ for tests.
This commit is contained in:
parent
f79434a8df
commit
7707dfbe86
4 changed files with 18 additions and 5 deletions
15
README.md
15
README.md
|
|
@ -547,6 +547,17 @@ pda dump
|
|||
|
||||
### Environment
|
||||
|
||||
Config is stored in your user config directory in `pda/config.toml`.
|
||||
|
||||
Usually: `~/.config/pda/config.toml`
|
||||
|
||||
`PDA_CONFIG` overrides the default config location. pda! will look for a config.toml file in that directory.
|
||||
```bash
|
||||
PDA_CONFIG=/tmp/config/ pda set key value
|
||||
```
|
||||
|
||||
<p align="center"></p><!-- spacer -->
|
||||
|
||||
Data is stored in your user data directory under `pda/stores/`.
|
||||
|
||||
Usually:
|
||||
|
|
@ -554,9 +565,9 @@ Usually:
|
|||
- macOS: `~/Library/Application Support/pda/stores/`
|
||||
- windows: `%LOCALAPPDATA%/pda/stores/`
|
||||
|
||||
`PDA_DATA_DIR` overrides the default storage location.
|
||||
`PDA_DATA` overrides the default storage location.
|
||||
```bash
|
||||
PDATA_DATA_DIR=/tmp/stores pda set key value
|
||||
PDA_DATA=/tmp/stores pda set key value
|
||||
```
|
||||
|
||||
<p align="center"></p><!-- spacer -->
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func (s *Store) open(name string) (*badger.DB, error) {
|
|||
}
|
||||
|
||||
func (s *Store) path(args ...string) (string, error) {
|
||||
if override := os.Getenv("PDA_DATA_DIR"); override != "" {
|
||||
if override := os.Getenv("PDA_DATA"); override != "" {
|
||||
if err := os.MkdirAll(override, 0o750); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ import (
|
|||
var update = flag.Bool("update", false, "update test files with results")
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
t.Setenv("PDA_DATA_DIR", t.TempDir())
|
||||
t.Setenv("PDA_DATA", t.TempDir())
|
||||
t.Setenv("PDA_CONFIG", t.TempDir())
|
||||
ts, err := cmdtest.Read("testdata")
|
||||
if err != nil {
|
||||
t.Fatalf("read testdata: %v", err)
|
||||
|
|
|
|||
|
|
@ -63,4 +63,5 @@ Set Height 600
|
|||
Set BorderRadius 5
|
||||
Set PlaybackSpeed 0.8
|
||||
|
||||
Env PDA_DATA_DIR "/tmp/pda-demo"
|
||||
Env PDA_DATA "/tmp/pda-demo"
|
||||
Env PDA_CONFIG "/tmp/pda-config"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue