-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated
ls-icon
and icon fetching mechanism
- Loading branch information
yusing
committed
Jan 12, 2025
1 parent
d887a37
commit e10e6cf
Showing
5 changed files
with
191 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package homepage | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/yusing/go-proxy/internal/utils/testing" | ||
) | ||
|
||
func TestIconURL(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
wantValue *IconURL | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "absolute", | ||
input: "http://example.com/icon.png", | ||
wantValue: &IconURL{ | ||
Value: "http://example.com/icon.png", | ||
IconSource: IconSourceAbsolute, | ||
}, | ||
}, | ||
{ | ||
name: "relative", | ||
input: "@target/icon.png", | ||
wantValue: &IconURL{ | ||
Value: "/icon.png", | ||
IconSource: IconSourceRelative, | ||
}, | ||
}, | ||
{ | ||
name: "walkxcode", | ||
input: "png/walkxcode.png", | ||
wantValue: &IconURL{ | ||
Value: "png/walkxcode.png", | ||
IconSource: IconSourceWalkXCode, | ||
Extra: &IconExtra{ | ||
FileType: "png", | ||
Name: "walkxcode", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "invalid", | ||
input: "invalid", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "empty", | ||
input: "", | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
u := &IconURL{} | ||
err := u.Parse(tc.input) | ||
if tc.wantErr { | ||
ExpectError(t, ErrInvalidIconURL, err) | ||
} else { | ||
ExpectNoError(t, err) | ||
ExpectDeepEqual(t, u, tc.wantValue) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters