mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
fixed some tests
This commit is contained in:
parent
60f83bb7bf
commit
e3e3f1dfdc
5 changed files with 28 additions and 33 deletions
|
@ -7,25 +7,30 @@ import (
|
|||
)
|
||||
|
||||
func TestOverrideItem(t *testing.T) {
|
||||
// a := &Item{
|
||||
// Show: false,
|
||||
// Alias: "foo",
|
||||
// Name: "Foo",
|
||||
// Icon: &IconURL{
|
||||
// Value: "/favicon.ico",
|
||||
// IconSource: IconSourceRelative,
|
||||
// },
|
||||
// Category: "App",
|
||||
// }
|
||||
// overrides := GetJSONConfig()
|
||||
// overrides.SetShowItemOverride(a.Alias, true)
|
||||
// overrides.SetDisplayNameOverride(a.Alias, "Bar")
|
||||
// overrides.SetDisplayCategoryOverride(a.Alias, "Test")
|
||||
// ExpectNoError(t, overrides.SetIconOverride(a.Alias, "@walkxcode/example.png"))
|
||||
|
||||
// overridden := a.GetOverriddenItem()
|
||||
// ExpectTrue(t, overridden.Show)
|
||||
// ExpectEqual(t, overridden.Name, "Bar")
|
||||
// ExpectEqual(t, overridden.Category, "Test")
|
||||
// ExpectEqual(t, overridden.Icon.String(), "png/example.png")
|
||||
InitOverridesConfig()
|
||||
a := &Item{
|
||||
Alias: "foo",
|
||||
ItemConfig: &ItemConfig{
|
||||
Show: false,
|
||||
Name: "Foo",
|
||||
Icon: &IconURL{
|
||||
Value: "/favicon.ico",
|
||||
IconSource: IconSourceRelative,
|
||||
},
|
||||
Category: "App",
|
||||
},
|
||||
}
|
||||
override := &ItemConfig{
|
||||
Show: true,
|
||||
Name: "Bar",
|
||||
Category: "Test",
|
||||
Icon: &IconURL{
|
||||
Value: "@walkxcode/example.png",
|
||||
IconSource: IconSourceWalkXCode,
|
||||
},
|
||||
}
|
||||
overrides := GetOverrideConfig()
|
||||
overrides.OverrideItem(a.Alias, override)
|
||||
overridden := a.GetOverride()
|
||||
ExpectDeepEqual(t, overridden.ItemConfig, override)
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ func TestIconURL(t *testing.T) {
|
|||
if tc.wantErr {
|
||||
ExpectError(t, ErrInvalidIconURL, err)
|
||||
} else {
|
||||
tc.wantValue.FullValue = tc.input
|
||||
ExpectNoError(t, err)
|
||||
ExpectDeepEqual(t, u, tc.wantValue)
|
||||
}
|
||||
|
|
|
@ -19,13 +19,6 @@ type OverrideConfig struct {
|
|||
|
||||
var overrideConfigInstance *OverrideConfig
|
||||
|
||||
func must(b []byte, err error) []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func InitOverridesConfig() {
|
||||
overrideConfigInstance = &OverrideConfig{
|
||||
ItemOverrides: make(map[string]*ItemConfig),
|
||||
|
|
|
@ -133,6 +133,7 @@ func escapeAndAppend(s string, buf *[]byte) {
|
|||
*buf = append(*buf, "	"...)
|
||||
case '\n':
|
||||
*buf = append(*buf, "<br>"...)
|
||||
*buf = append(*buf, prefixHTML...)
|
||||
default:
|
||||
*buf = append(*buf, s[i])
|
||||
}
|
||||
|
|
|
@ -39,11 +39,6 @@ func TestParseCommands(t *testing.T) {
|
|||
input: "rewrite / / /",
|
||||
wantErr: ErrInvalidArguments,
|
||||
},
|
||||
{
|
||||
name: "rewrite_no_leading_slash",
|
||||
input: "rewrite abc /",
|
||||
wantErr: ErrInvalidArguments,
|
||||
},
|
||||
// serve tests
|
||||
{
|
||||
name: "serve_valid",
|
||||
|
|
Loading…
Add table
Reference in a new issue