mirror of
https://github.com/Mic92/sops-nix.git
synced 2026-02-04 03:53:50 +08:00
Rework restart-and-reload to assert more strictly on the activation output
I've reworked the test to assert on the entire output. This allows us to detect unexpected output without having to write weird "i expect this random string to *not* show up assertions", which aren't great at preventing regressions. I did have to change the code under test a little bit to make it behavior deterministically (by sorting the files it outputs). tl;dr: this demonstrates <https://github.com/Mic92/sops-nix/issues/652> but does not fix it. I will fix it in a subsequent commit.
This commit is contained in:
parent
c5ae1e214f
commit
33f18b404e
2 changed files with 89 additions and 38 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
|
@ -984,12 +985,15 @@ func handleModifications(isDry bool, logcfg loggingConfig, symlinkPath string, s
|
|||
} else {
|
||||
fmt.Printf("%s secret%s: ", regularPrefix, s)
|
||||
}
|
||||
comma := ""
|
||||
for name := range changed {
|
||||
fmt.Printf("%s%s", comma, name)
|
||||
comma = ", "
|
||||
|
||||
// Sort the output for deterministic behavior.
|
||||
keys := make([]string, 0, len(changed))
|
||||
for key := range changed {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
fmt.Println()
|
||||
sort.Strings(keys)
|
||||
|
||||
fmt.Println(strings.Join(keys, ", "))
|
||||
}
|
||||
}
|
||||
outputChanged(newSecrets, "adding", "would add")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue