rename helper function;

This commit is contained in:
naudachu 2023-11-09 17:47:47 +05:00
parent 23de9a3db7
commit 3f365a715f
5 changed files with 8 additions and 6 deletions

View File

@ -49,6 +49,7 @@ type TelegramConfig struct {
type DiscordConfig struct { type DiscordConfig struct {
Token string Token string
ProjectsChannelID string
} }
type ApplicationConfig struct { type ApplicationConfig struct {
@ -93,6 +94,7 @@ func InitConfig(envFilePath string) Config {
}, },
Discord: DiscordConfig{ Discord: DiscordConfig{
Token: os.Getenv("DISCORD_TOKEN"), Token: os.Getenv("DISCORD_TOKEN"),
ProjectsChannelID: os.Getenv("PROJECTS_CHANNEL_GROUP"),
}, },
} }
} }

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
) )
func ValidNaming(input string) string { func Cut(input string) string {
// Remove leading and trailing whitespace // Remove leading and trailing whitespace
input = strings.TrimSpace(input) input = strings.TrimSpace(input)

View File

@ -18,7 +18,7 @@ var tests = []test{
func TestGitNaming(t *testing.T) { func TestGitNaming(t *testing.T) {
for _, test := range tests { for _, test := range tests {
if output := ValidNaming(test.arg); output != test.expected { if output := Cut(test.arg); output != test.expected {
t.Errorf("Output %q not equal to expected %q", output, test.expected) t.Errorf("Output %q not equal to expected %q", output, test.expected)
} }
} }

View File

@ -49,7 +49,7 @@ func (c *Cloud) CreateFolder(name string) Response {
davPath := "/remote.php/dav/files/" davPath := "/remote.php/dav/files/"
parentPath := "/apps/files/?dir=" parentPath := "/apps/files/?dir="
name = helpers.ValidNaming(name) name = helpers.Cut(name)
R.Folder = &domain.Folder{ R.Folder = &domain.Folder{
Title: name, Title: name,

View File

@ -55,7 +55,7 @@ type gitCreateRequest struct {
} }
func (gb *Git) newRepo(name string) (*domain.Git, error) { func (gb *Git) newRepo(name string) (*domain.Git, error) {
name = helpers.ValidNaming(name) name = helpers.Cut(name)
payload := gitCreateRequest{ payload := gitCreateRequest{
Name: name, Name: name,