chrly/http/http_test.go

47 lines
1.1 KiB
Go
Raw Normal View History

package http
import (
"testing"
"github.com/golang/mock/gomock"
testify "github.com/stretchr/testify/assert"
"elyby/minecraft-skinsystem/interfaces/mock_interfaces"
"elyby/minecraft-skinsystem/interfaces/mock_wd"
)
func TestParseUsername(t *testing.T) {
assert := testify.New(t)
assert.Equal("test", parseUsername("test.png"), "Function should trim .png at end")
assert.Equal("test", parseUsername("test"), "Function should return string itself, if it not contains .png at end")
}
2018-01-23 02:46:42 +05:30
type mocks struct {
Skins *mock_interfaces.MockSkinsRepository
Capes *mock_interfaces.MockCapesRepository
Auth *mock_interfaces.MockAuthChecker
2018-01-23 02:46:42 +05:30
Log *mock_wd.MockWatchdog
}
func setupMocks(ctrl *gomock.Controller) (
*Config,
2018-01-23 02:46:42 +05:30
*mocks,
) {
skinsRepo := mock_interfaces.NewMockSkinsRepository(ctrl)
capesRepo := mock_interfaces.NewMockCapesRepository(ctrl)
authChecker := mock_interfaces.NewMockAuthChecker(ctrl)
wd := mock_wd.NewMockWatchdog(ctrl)
return &Config{
SkinsRepo: skinsRepo,
CapesRepo: capesRepo,
Auth: authChecker,
2018-01-23 02:46:42 +05:30
Logger: wd,
}, &mocks{
Skins: skinsRepo,
Capes: capesRepo,
Auth: authChecker,
2018-01-23 02:46:42 +05:30
Log: wd,
}
}