mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-01 21:31:18 -08:00
a8f246064e
For supported shells: - Correct string quoting. - Reorganize initialization scripts to improve maintainability.
35 lines
797 B
Go
35 lines
797 B
Go
package shell
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestBashFeatures(t *testing.T) {
|
|
got := allFeatures.Lines(BASH).String("// these are the features")
|
|
|
|
want := `// these are the features
|
|
_omp_ftcs_marks=1
|
|
"$_omp_executable" upgrade
|
|
"$_omp_executable" notice
|
|
_omp_cursor_positioning=1`
|
|
|
|
assert.Equal(t, want, got)
|
|
}
|
|
|
|
func TestQuotePosixStr(t *testing.T) {
|
|
tests := []struct {
|
|
str string
|
|
expected string
|
|
}{
|
|
{str: "", expected: "''"},
|
|
{str: `/tmp/"omp's dir"/oh-my-posh`, expected: `$'/tmp/"omp\'s dir"/oh-my-posh'`},
|
|
{str: `C:/tmp\omp's dir/oh-my-posh.exe`, expected: `$'C:/tmp\\omp\'s dir/oh-my-posh.exe'`},
|
|
}
|
|
for _, tc := range tests {
|
|
assert.Equal(t, tc.expected, QuotePosixStr(tc.str), fmt.Sprintf("QuotePosixStr: %s", tc.str))
|
|
}
|
|
}
|