2016-07-06 03:55:05 +05:30
|
|
|
package tools_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
. "elyby/minecraft-skinsystem/lib/tools"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseUsername(t *testing.T) {
|
|
|
|
if ParseUsername("test.png") != "test" {
|
|
|
|
t.Error("Function should trim .png at end")
|
|
|
|
}
|
|
|
|
|
|
|
|
if ParseUsername("test") != "test" {
|
|
|
|
t.Error("Function should return string itself, if it not contains .png at end")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildKey(t *testing.T) {
|
|
|
|
if BuildKey("Test") != "username:test" {
|
2016-07-06 17:15:14 +05:30
|
|
|
t.Error("Function shound convert string to lower case and concatenate it with usernmae:")
|
2016-07-06 03:55:05 +05:30
|
|
|
}
|
|
|
|
}
|
2017-04-13 16:50:04 +05:30
|
|
|
|
|
|
|
func TestBuildElyUrl(t *testing.T) {
|
|
|
|
if BuildElyUrl("/route") != "http://ely.by/route" {
|
|
|
|
t.Error("Function should add prefix to the provided relative url.")
|
|
|
|
}
|
|
|
|
|
|
|
|
if BuildElyUrl("http://ely.by/test/route") != "http://ely.by/test/route" {
|
|
|
|
t.Error("Function should do not add prefix to the provided prefixed url.")
|
|
|
|
}
|
|
|
|
}
|