mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 15:11:53 +08:00

* fix(pkg): Fixed an issue where wails new would throw an error if the author name contained non-JSON legal characters. * refactor(pkg): Incorporating coderabbit's suggestions * docs: write changelog.mdx * Escape using json package. Add tests. * Update test. --------- Co-authored-by: Lea O'Anthony <lea.anthony@gmail.com>
45 lines
747 B
Go
45 lines
747 B
Go
package git
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestEscapeName1(t *testing.T) {
|
|
type args struct {
|
|
str string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "Escape Apostrophe",
|
|
args: args{
|
|
str: `John O'Keefe`,
|
|
},
|
|
want: `John O'Keefe`,
|
|
},
|
|
{
|
|
name: "Escape backslash",
|
|
args: args{
|
|
str: `MYDOMAIN\USER`,
|
|
},
|
|
want: `MYDOMAIN\\USER`,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := EscapeName(tt.args.str)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("EscapeName() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if got != tt.want {
|
|
t.Errorf("EscapeName() got = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|