MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestShellPath

Function TestShellPath

internal/postgres/config_test.go:550–579  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

548}
549
550func TestShellPath(t *testing.T) {
551 t.Parallel()
552
553 script := ShellPath(11)
554
555 assert.Assert(t, cmp.Contains(script, `/usr/lib/postgresql/11/bin`))
556 assert.Assert(t, cmp.Contains(script, `/usr/libexec/postgresql11`))
557 assert.Assert(t, cmp.Contains(script, `/usr/pgsql-11/bin`))
558
559 t.Run("ShellCheckPOSIX", func(t *testing.T) {
560 shellcheck := require.ShellCheck(t)
561
562 dir := t.TempDir()
563 file := filepath.Join(dir, "script.sh")
564 assert.NilError(t, os.WriteFile(file, []byte(script), 0o600))
565
566 // Expect ShellCheck for "sh" to be happy.
567 // - https://www.shellcheck.net/wiki/SC2148
568 cmd := exec.CommandContext(t.Context(), shellcheck, "--enable=all", "--shell=sh", file)
569 output, err := cmd.CombinedOutput()
570 assert.NilError(t, err, "%q\n%s", cmd.Args, output)
571 })
572
573 t.Run("PrettyYAML", func(t *testing.T) {
574 b, err := yaml.Marshal(script)
575 assert.NilError(t, err)
576 assert.Assert(t, !strings.Contains(string(b), `\n`), "expected literal flow scalar, got:\n%s", b)
577 assert.Equal(t, 1, strings.Count(string(b), "\n"), "expected one trailing newline, got:\n%s", b)
578 })
579}
580
581func TestStartupCommand(t *testing.T) {
582 shellcheck := require.ShellCheck(t)

Callers

nothing calls this directly

Calls 4

ContainsFunction · 0.92
ShellCheckFunction · 0.92
ShellPathFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected