0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-10-25 03:34:47 -04:00
Files
gitea/services/secrets/validation_test.go
Giteabot 4af1d58c86 Fix various bugs (#35684) (#35696)
Backport #35684 by wxiaoguang
2025-10-19 02:26:03 +08:00

30 lines
562 B
Go

// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package secrets
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidateName(t *testing.T) {
cases := []struct {
name string
valid bool
}{
{"FOO", true},
{"FOO1_BAR2", true},
{"_FOO", true}, // really? why support this
{"1FOO", false},
{"giteA_xx", false},
{"githuB_xx", false},
{"cI", false},
}
for _, c := range cases {
err := ValidateName(c.name)
assert.Equal(t, c.valid, err == nil, "ValidateName(%q)", c.name)
}
}