mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 04:16:25 +08:00
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestReplace(t *testing.T) {
|
|
foobar := `;:.,-_$\£!^`
|
|
|
|
samples := [][2]string{
|
|
{"{foobar}", foobar},
|
|
{"{foobar^:}", `;\:.,-_$\\£!^`},
|
|
{"{foobar^:}barfoo{foobar^:}", `;\:.,-_$\\£!^barfoo;\:.,-_$\\£!^`},
|
|
{"{foobar^:.}", "{foobar^:.}"},
|
|
{"{foobar^}", "{foobar^}"},
|
|
{"{barfoo^:}", "{barfoo^:}"},
|
|
{"{foobar^^}", `;:.,-_$\\£!\^`},
|
|
{`{foobar^\}`, `;:.,-_$\\£!^`},
|
|
}
|
|
|
|
for _, e := range samples {
|
|
replaced := replace(e[0], "foobar", foobar)
|
|
require.Equal(t, e[1], replaced, e[0])
|
|
}
|
|
}
|
|
|
|
func TestCreateCommand(t *testing.T) {
|
|
config := &Config{
|
|
Options: []string{"-global", "global"},
|
|
Input: []ConfigIO{
|
|
{Address: "inputAddress", Options: []string{"-input", "inputoption"}},
|
|
},
|
|
Output: []ConfigIO{
|
|
{Address: "outputAddress", Options: []string{"-output", "oututoption"}},
|
|
},
|
|
}
|
|
|
|
command := config.CreateCommand()
|
|
require.Equal(t, []string{
|
|
"-global", "global",
|
|
"-input", "inputoption", "-i", "inputAddress",
|
|
"-output", "oututoption", "outputAddress",
|
|
}, command)
|
|
}
|