Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367)
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
This commit is contained in:
parent
51ff4970ec
commit
fed2d81c44
427 changed files with 2043 additions and 2046 deletions
|
@ -53,7 +53,7 @@ func TestLayered(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
bs, err := io.ReadAll(f)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "f1", string(bs))
|
||||
assert.Equal(t, "f1", string(bs))
|
||||
_ = f.Close()
|
||||
|
||||
assertRead := func(expected string, expectedErr error, elems ...string) {
|
||||
|
@ -77,27 +77,27 @@ func TestLayered(t *testing.T) {
|
|||
|
||||
files, err := assets.ListFiles(".", true)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"f1", "f2", "fa"}, files)
|
||||
assert.Equal(t, []string{"f1", "f2", "fa"}, files)
|
||||
|
||||
files, err = assets.ListFiles(".", false)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"d1", "d2", "da"}, files)
|
||||
assert.Equal(t, []string{"d1", "d2", "da"}, files)
|
||||
|
||||
files, err = assets.ListFiles(".")
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"d1", "d2", "da", "f1", "f2", "fa"}, files)
|
||||
assert.Equal(t, []string{"d1", "d2", "da", "f1", "f2", "fa"}, files)
|
||||
|
||||
files, err = assets.ListAllFiles(".", true)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"d1/f", "d2/f", "da/f", "f1", "f2", "fa"}, files)
|
||||
assert.Equal(t, []string{"d1/f", "d2/f", "da/f", "f1", "f2", "fa"}, files)
|
||||
|
||||
files, err = assets.ListAllFiles(".", false)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"d1", "d2", "da", "da/sub1", "da/sub2"}, files)
|
||||
assert.Equal(t, []string{"d1", "d2", "da", "da/sub1", "da/sub2"}, files)
|
||||
|
||||
files, err = assets.ListAllFiles(".")
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{
|
||||
assert.Equal(t, []string{
|
||||
"d1", "d1/f",
|
||||
"d2", "d2/f",
|
||||
"da", "da/f", "da/sub1", "da/sub2",
|
||||
|
@ -105,6 +105,6 @@ func TestLayered(t *testing.T) {
|
|||
}, files)
|
||||
|
||||
assert.Empty(t, assets.GetFileLayerName("no-such"))
|
||||
assert.EqualValues(t, "l1", assets.GetFileLayerName("f1"))
|
||||
assert.EqualValues(t, "l2", assets.GetFileLayerName("f2"))
|
||||
assert.Equal(t, "l1", assets.GetFileLayerName("f1"))
|
||||
assert.Equal(t, "l2", assets.GetFileLayerName("f2"))
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ func Test_ProcessAvatarImage(t *testing.T) {
|
|||
assert.NotEqual(t, origin, result)
|
||||
decoded, err := png.Decode(bytes.NewReader(result))
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, scaledSize, decoded.Bounds().Max.X)
|
||||
assert.EqualValues(t, scaledSize, decoded.Bounds().Max.Y)
|
||||
assert.Equal(t, scaledSize, decoded.Bounds().Max.X)
|
||||
assert.Equal(t, scaledSize, decoded.Bounds().Max.Y)
|
||||
|
||||
// if origin image is smaller than the default size, use the origin image
|
||||
origin = newImgData(1)
|
||||
|
|
|
@ -19,8 +19,8 @@ func Test_HashAvatar(t *testing.T) {
|
|||
var buff bytes.Buffer
|
||||
png.Encode(&buff, myImage)
|
||||
|
||||
assert.EqualValues(t, "9ddb5bac41d57e72aa876321d0c09d71090c05f94bc625303801be2f3240d2cb", avatar.HashAvatar(1, buff.Bytes()))
|
||||
assert.EqualValues(t, "9a5d44e5d637b9582a976676e8f3de1dccd877c2fe3e66ca3fab1629f2f47609", avatar.HashAvatar(8, buff.Bytes()))
|
||||
assert.EqualValues(t, "ed7399158672088770de6f5211ce15528ebd675e92fc4fc060c025f4b2794ccb", avatar.HashAvatar(1024, buff.Bytes()))
|
||||
assert.EqualValues(t, "161178642c7d59eb25a61dddced5e6b66eae1c70880d5f148b1b497b767e72d9", avatar.HashAvatar(1024, []byte{}))
|
||||
assert.Equal(t, "9ddb5bac41d57e72aa876321d0c09d71090c05f94bc625303801be2f3240d2cb", avatar.HashAvatar(1, buff.Bytes()))
|
||||
assert.Equal(t, "9a5d44e5d637b9582a976676e8f3de1dccd877c2fe3e66ca3fab1629f2f47609", avatar.HashAvatar(8, buff.Bytes()))
|
||||
assert.Equal(t, "ed7399158672088770de6f5211ce15528ebd675e92fc4fc060c025f4b2794ccb", avatar.HashAvatar(1024, buff.Bytes()))
|
||||
assert.Equal(t, "161178642c7d59eb25a61dddced5e6b66eae1c70880d5f148b1b497b767e72d9", avatar.HashAvatar(1024, []byte{}))
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func TestEllipsisString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTruncateString(t *testing.T) {
|
||||
assert.Equal(t, "", TruncateString("foobar", 0))
|
||||
assert.Empty(t, TruncateString("foobar", 0))
|
||||
assert.Equal(t, "f", TruncateString("foobar", 1))
|
||||
assert.Equal(t, "fo", TruncateString("foobar", 2))
|
||||
assert.Equal(t, "foo", TruncateString("foobar", 3))
|
||||
|
@ -125,5 +125,5 @@ func TestFormatNumberSI(t *testing.T) {
|
|||
assert.Equal(t, "1.3k", FormatNumberSI(int64(1317)))
|
||||
assert.Equal(t, "21.3M", FormatNumberSI(21317675))
|
||||
assert.Equal(t, "45.7G", FormatNumberSI(45721317675))
|
||||
assert.Equal(t, "", FormatNumberSI("test"))
|
||||
assert.Empty(t, FormatNumberSI("test"))
|
||||
}
|
||||
|
|
6
modules/cache/cache_test.go
vendored
6
modules/cache/cache_test.go
vendored
|
@ -48,19 +48,19 @@ func TestGetString(t *testing.T) {
|
|||
return "", fmt.Errorf("some error")
|
||||
})
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, "", data)
|
||||
assert.Empty(t, data)
|
||||
|
||||
data, err = GetString("key", func() (string, error) {
|
||||
return "", nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", data)
|
||||
assert.Empty(t, data)
|
||||
|
||||
data, err = GetString("key", func() (string, error) {
|
||||
return "some data", nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", data)
|
||||
assert.Empty(t, data)
|
||||
Remove("key")
|
||||
|
||||
data, err = GetString("key", func() (string, error) {
|
||||
|
|
4
modules/cache/context_test.go
vendored
4
modules/cache/context_test.go
vendored
|
@ -23,7 +23,7 @@ func TestWithCacheContext(t *testing.T) {
|
|||
SetContextData(ctx, field, "my_config1", 1)
|
||||
v = GetContextData(ctx, field, "my_config1")
|
||||
assert.NotNil(t, v)
|
||||
assert.EqualValues(t, 1, v.(int))
|
||||
assert.Equal(t, 1, v.(int))
|
||||
|
||||
RemoveContextData(ctx, field, "my_config1")
|
||||
RemoveContextData(ctx, field, "my_config2") // remove a non-exist key
|
||||
|
@ -35,7 +35,7 @@ func TestWithCacheContext(t *testing.T) {
|
|||
return 1, nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 1, vInt)
|
||||
assert.Equal(t, 1, vInt)
|
||||
|
||||
v = GetContextData(ctx, field, "my_config1")
|
||||
assert.EqualValues(t, 1, v)
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
func TestAmbiguousCharacters(t *testing.T) {
|
||||
for locale, ambiguous := range AmbiguousCharacters {
|
||||
assert.Equal(t, locale, ambiguous.Locale)
|
||||
assert.Equal(t, len(ambiguous.Confusable), len(ambiguous.With))
|
||||
assert.Len(t, ambiguous.With, len(ambiguous.Confusable))
|
||||
assert.True(t, sort.SliceIsSorted(ambiguous.Confusable, func(i, j int) bool {
|
||||
return ambiguous.Confusable[i] < ambiguous.Confusable[j]
|
||||
}))
|
||||
|
|
|
@ -253,7 +253,7 @@ func TestToUTF8WithFallbackReader(t *testing.T) {
|
|||
input += "// Выключаем"
|
||||
rd := ToUTF8WithFallbackReader(bytes.NewReader([]byte(input)), ConvertOpts{})
|
||||
r, _ := io.ReadAll(rd)
|
||||
assert.EqualValuesf(t, input, string(r), "testing string len=%d", testLen)
|
||||
assert.Equalf(t, input, string(r), "testing string len=%d", testLen)
|
||||
}
|
||||
|
||||
truncatedOneByteExtension := failFastBytes
|
||||
|
|
|
@ -151,7 +151,7 @@ func (e *escapeStreamer) brokenRune(bs []byte) error {
|
|||
e.escaped.Escaped = true
|
||||
e.escaped.HasBadRunes = true
|
||||
|
||||
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
|
||||
if err := e.StartTag("span", html.Attribute{
|
||||
Key: "class",
|
||||
Val: "broken-code-point",
|
||||
}); err != nil {
|
||||
|
@ -161,14 +161,14 @@ func (e *escapeStreamer) brokenRune(bs []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return e.PassthroughHTMLStreamer.EndTag("span")
|
||||
return e.EndTag("span")
|
||||
}
|
||||
|
||||
func (e *escapeStreamer) ambiguousRune(r, c rune) error {
|
||||
e.escaped.Escaped = true
|
||||
e.escaped.HasAmbiguous = true
|
||||
|
||||
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
|
||||
if err := e.StartTag("span", html.Attribute{
|
||||
Key: "class",
|
||||
Val: "ambiguous-code-point",
|
||||
}, html.Attribute{
|
||||
|
@ -177,7 +177,7 @@ func (e *escapeStreamer) ambiguousRune(r, c rune) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
|
||||
if err := e.StartTag("span", html.Attribute{
|
||||
Key: "class",
|
||||
Val: "char",
|
||||
}); err != nil {
|
||||
|
@ -186,18 +186,18 @@ func (e *escapeStreamer) ambiguousRune(r, c rune) error {
|
|||
if err := e.PassthroughHTMLStreamer.Text(string(r)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := e.PassthroughHTMLStreamer.EndTag("span"); err != nil {
|
||||
if err := e.EndTag("span"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return e.PassthroughHTMLStreamer.EndTag("span")
|
||||
return e.EndTag("span")
|
||||
}
|
||||
|
||||
func (e *escapeStreamer) invisibleRune(r rune) error {
|
||||
e.escaped.Escaped = true
|
||||
e.escaped.HasInvisible = true
|
||||
|
||||
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
|
||||
if err := e.StartTag("span", html.Attribute{
|
||||
Key: "class",
|
||||
Val: "escaped-code-point",
|
||||
}, html.Attribute{
|
||||
|
@ -206,7 +206,7 @@ func (e *escapeStreamer) invisibleRune(r rune) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
|
||||
if err := e.StartTag("span", html.Attribute{
|
||||
Key: "class",
|
||||
Val: "char",
|
||||
}); err != nil {
|
||||
|
@ -215,11 +215,11 @@ func (e *escapeStreamer) invisibleRune(r rune) error {
|
|||
if err := e.PassthroughHTMLStreamer.Text(string(r)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := e.PassthroughHTMLStreamer.EndTag("span"); err != nil {
|
||||
if err := e.EndTag("span"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return e.PassthroughHTMLStreamer.EndTag("span")
|
||||
return e.EndTag("span")
|
||||
}
|
||||
|
||||
type runeCountType struct {
|
||||
|
|
|
@ -190,5 +190,5 @@ func TestAmbiguousUnicodeDetectionContext(t *testing.T) {
|
|||
assert.EqualValues(t, `a<span class="escaped-code-point" data-escaped="[U+00A0]"><span class="char"> </span></span>test`, out)
|
||||
|
||||
_, out = EscapeControlHTML(input, &translation.MockLocale{}, testContext)
|
||||
assert.EqualValues(t, input, out)
|
||||
assert.Equal(t, input, out)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestSet(t *testing.T) {
|
|||
called++
|
||||
assert.True(t, slices.Contains(values, value))
|
||||
}
|
||||
assert.EqualValues(t, len(values), called)
|
||||
assert.Equal(t, len(values), called)
|
||||
|
||||
s = SetOf("key6", "key7")
|
||||
assert.False(t, s.Contains("key1"))
|
||||
|
|
|
@ -101,10 +101,10 @@ j, ,\x20
|
|||
for n, c := range cases {
|
||||
rd, err := CreateReaderAndDetermineDelimiter(nil, strings.NewReader(decodeSlashes(t, c.csv)))
|
||||
require.NoError(t, err, "case %d: should not throw error: %v\n", n, err)
|
||||
assert.EqualValues(t, c.expectedDelimiter, rd.Comma, "case %d: delimiter should be '%c', got '%c'", n, c.expectedDelimiter, rd.Comma)
|
||||
assert.Equal(t, c.expectedDelimiter, rd.Comma, "case %d: delimiter should be '%c', got '%c'", n, c.expectedDelimiter, rd.Comma)
|
||||
rows, err := rd.ReadAll()
|
||||
require.NoError(t, err, "case %d: should not throw error: %v\n", n, err)
|
||||
assert.EqualValues(t, c.expectedRows, rows, "case %d: rows should be equal", n)
|
||||
assert.Equal(t, c.expectedRows, rows, "case %d: rows should be equal", n)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ John Doe john@doe.com This,note,had,a,lot,of,commas,to,test,delimiters`,
|
|||
Ctx: git.DefaultContext,
|
||||
RelativePath: c.filename,
|
||||
}, []byte(decodeSlashes(t, c.csv)))
|
||||
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
|
||||
assert.Equal(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ abc | |123
|
|||
|
||||
for n, c := range cases {
|
||||
modifiedText := removeQuotedString(decodeSlashes(t, c.text))
|
||||
assert.EqualValues(t, c.expectedText, modifiedText, "case %d: modified text should be equal", n)
|
||||
assert.Equal(t, c.expectedText, modifiedText, "case %d: modified text should be equal", n)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ jkl`,
|
|||
|
||||
for n, c := range cases {
|
||||
delimiter := guessDelimiter([]byte(decodeSlashes(t, c.csv)))
|
||||
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
|
||||
assert.Equal(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ a|"he said, ""here I am"""`,
|
|||
|
||||
for n, c := range cases {
|
||||
delimiter := guessFromBeforeAfterQuotes([]byte(decodeSlashes(t, c.csv)))
|
||||
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
|
||||
assert.Equal(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ func TestFormatError(t *testing.T) {
|
|||
require.Error(t, err, "case %d: expected an error to be returned", n)
|
||||
} else {
|
||||
require.NoError(t, err, "case %d: no error was expected, got error: %v", n, err)
|
||||
assert.EqualValues(t, c.expectedMessage, message, "case %d: messages should be equal, expected '%s' got '%s'", n, c.expectedMessage, message)
|
||||
assert.Equal(t, c.expectedMessage, message, "case %d: messages should be equal, expected '%s' got '%s'", n, c.expectedMessage, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ func TestGitArgument(t *testing.T) {
|
|||
|
||||
func TestCommandString(t *testing.T) {
|
||||
cmd := NewCommandContextNoGlobals(t.Context(), "a", "-m msg", "it's a test", `say "hello"`)
|
||||
assert.EqualValues(t, cmd.prog+` a "-m msg" "it's a test" "say \"hello\""`, cmd.String())
|
||||
assert.Equal(t, cmd.prog+` a "-m msg" "it's a test" "say \"hello\""`, cmd.String())
|
||||
|
||||
cmd = NewCommandContextNoGlobals(t.Context(), "url: https://a:b@c/")
|
||||
assert.EqualValues(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
|
||||
assert.Equal(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
|
||||
}
|
||||
|
||||
func TestGrepOnlyFunction(t *testing.T) {
|
||||
|
|
|
@ -220,7 +220,7 @@ func (c *Commit) HasPreviousCommit(objectID ObjectID) (bool, error) {
|
|||
}
|
||||
var exitError *exec.ExitError
|
||||
if errors.As(err, &exitError) {
|
||||
if exitError.ProcessState.ExitCode() == 1 && len(exitError.Stderr) == 0 {
|
||||
if exitError.ExitCode() == 1 && len(exitError.Stderr) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ signed commit`
|
|||
return
|
||||
}
|
||||
assert.EqualValues(t, sha, commitFromReader.ID)
|
||||
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE-----
|
||||
assert.Equal(t, `-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIrBAABCgAtFiEES+fB08xlgTrzSdQvhkUIsBsmec8FAmU/wKoPHGFtYWplckBz
|
||||
dXNlLmRlAAoJEIZFCLAbJnnP4s4PQIJATa++WPzR6/H4etT7bsOGoMyguEJYyWOd
|
||||
|
@ -124,19 +124,19 @@ HKRr3NlRM/DygzTyj0gN74uoa0goCIbyAQhiT42nm0cuhM7uN/W0ayrlZjGF1cbR
|
|||
=xybZ
|
||||
-----END PGP SIGNATURE-----
|
||||
`, commitFromReader.Signature.Signature)
|
||||
assert.EqualValues(t, `tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
|
||||
assert.Equal(t, `tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
|
||||
parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8
|
||||
author Adam Majer <amajer@suse.de> 1698676906 +0100
|
||||
committer Adam Majer <amajer@suse.de> 1698676906 +0100
|
||||
|
||||
signed commit`, commitFromReader.Signature.Payload)
|
||||
assert.EqualValues(t, "Adam Majer <amajer@suse.de>", commitFromReader.Author.String())
|
||||
assert.Equal(t, "Adam Majer <amajer@suse.de>", commitFromReader.Author.String())
|
||||
|
||||
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n"))
|
||||
require.NoError(t, err)
|
||||
commitFromReader.CommitMessage += "\n\n"
|
||||
commitFromReader.Signature.Payload += "\n\n"
|
||||
assert.EqualValues(t, commitFromReader, commitFromReader2)
|
||||
assert.Equal(t, commitFromReader, commitFromReader2)
|
||||
}
|
||||
|
||||
func TestHasPreviousCommitSha256(t *testing.T) {
|
||||
|
|
|
@ -92,7 +92,7 @@ empty commit`
|
|||
require.NoError(t, err)
|
||||
require.NotNil(t, commitFromReader)
|
||||
assert.EqualValues(t, sha, commitFromReader.ID)
|
||||
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE-----
|
||||
assert.Equal(t, `-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCAAdFiEEWPb2jX6FS2mqyJRQLmK0HJOGlEMFAl00zmEACgkQLmK0HJOG
|
||||
lEMDFBAAhQKKqLD1VICygJMEB8t1gBmNLgvziOLfpX4KPWdPtBk3v/QJ7OrfMrVK
|
||||
|
@ -109,19 +109,19 @@ mfeFhT57UbE4qukTDIQ0Y0WM40UYRTakRaDY7ubhXgLgx09Cnp9XTVMsHgT6j9/i
|
|||
=FRsO
|
||||
-----END PGP SIGNATURE-----
|
||||
`, commitFromReader.Signature.Signature)
|
||||
assert.EqualValues(t, `tree f1a6cb52b2d16773290cefe49ad0684b50a4f930
|
||||
assert.Equal(t, `tree f1a6cb52b2d16773290cefe49ad0684b50a4f930
|
||||
parent 37991dec2c8e592043f47155ce4808d4580f9123
|
||||
author silverwind <me@silverwind.io> 1563741793 +0200
|
||||
committer silverwind <me@silverwind.io> 1563741793 +0200
|
||||
|
||||
empty commit`, commitFromReader.Signature.Payload)
|
||||
assert.EqualValues(t, "silverwind <me@silverwind.io>", commitFromReader.Author.String())
|
||||
assert.Equal(t, "silverwind <me@silverwind.io>", commitFromReader.Author.String())
|
||||
|
||||
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n"))
|
||||
require.NoError(t, err)
|
||||
commitFromReader.CommitMessage += "\n\n"
|
||||
commitFromReader.Signature.Payload += "\n\n"
|
||||
assert.EqualValues(t, commitFromReader, commitFromReader2)
|
||||
assert.Equal(t, commitFromReader, commitFromReader2)
|
||||
}
|
||||
|
||||
func TestCommitWithEncodingFromReader(t *testing.T) {
|
||||
|
@ -158,7 +158,7 @@ ISO-8859-1`
|
|||
require.NoError(t, err)
|
||||
require.NotNil(t, commitFromReader)
|
||||
assert.EqualValues(t, sha, commitFromReader.ID)
|
||||
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE-----
|
||||
assert.Equal(t, `-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQGzBAABCgAdFiEE9HRrbqvYxPT8PXbefPSEkrowAa8FAmYGg7IACgkQfPSEkrow
|
||||
Aa9olwv+P0HhtCM6CRvlUmPaqswRsDPNR4i66xyXGiSxdI9V5oJL7HLiQIM7KrFR
|
||||
|
@ -173,20 +173,20 @@ jw4YcO5u
|
|||
=r3UU
|
||||
-----END PGP SIGNATURE-----
|
||||
`, commitFromReader.Signature.Signature)
|
||||
assert.EqualValues(t, `tree ca3fad42080dd1a6d291b75acdfc46e5b9b307e5
|
||||
assert.Equal(t, `tree ca3fad42080dd1a6d291b75acdfc46e5b9b307e5
|
||||
parent 47b24e7ab977ed31c5a39989d570847d6d0052af
|
||||
author KN4CK3R <admin@oldschoolhack.me> 1711702962 +0100
|
||||
committer KN4CK3R <admin@oldschoolhack.me> 1711702962 +0100
|
||||
encoding ISO-8859-1
|
||||
|
||||
ISO-8859-1`, commitFromReader.Signature.Payload)
|
||||
assert.EqualValues(t, "KN4CK3R <admin@oldschoolhack.me>", commitFromReader.Author.String())
|
||||
assert.Equal(t, "KN4CK3R <admin@oldschoolhack.me>", commitFromReader.Author.String())
|
||||
|
||||
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n"))
|
||||
require.NoError(t, err)
|
||||
commitFromReader.CommitMessage += "\n\n"
|
||||
commitFromReader.Signature.Payload += "\n\n"
|
||||
assert.EqualValues(t, commitFromReader, commitFromReader2)
|
||||
assert.Equal(t, commitFromReader, commitFromReader2)
|
||||
}
|
||||
|
||||
func TestHasPreviousCommit(t *testing.T) {
|
||||
|
|
|
@ -162,8 +162,8 @@ func BenchmarkCutDiffAroundLine(b *testing.B) {
|
|||
|
||||
func TestParseDiffHunkString(t *testing.T) {
|
||||
leftLine, leftHunk, rightLine, rightHunk := ParseDiffHunkString("@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER")
|
||||
assert.EqualValues(t, 19, leftLine)
|
||||
assert.EqualValues(t, 3, leftHunk)
|
||||
assert.EqualValues(t, 19, rightLine)
|
||||
assert.EqualValues(t, 5, rightHunk)
|
||||
assert.Equal(t, 19, leftLine)
|
||||
assert.Equal(t, 3, leftHunk)
|
||||
assert.Equal(t, 19, rightLine)
|
||||
assert.Equal(t, 5, rightHunk)
|
||||
}
|
||||
|
|
|
@ -120,10 +120,7 @@ func (err *ErrPushRejected) GenerateMessage() {
|
|||
err.Message = ""
|
||||
return
|
||||
}
|
||||
for {
|
||||
if len(err.StdErr) <= i+8 {
|
||||
break
|
||||
}
|
||||
for len(err.StdErr) > i+8 {
|
||||
if err.StdErr[i:i+8] != "remote: " {
|
||||
break
|
||||
}
|
||||
|
|
|
@ -118,11 +118,12 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int
|
|||
g.buffull = false
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
if err == bufio.ErrBufferFull {
|
||||
switch err {
|
||||
case bufio.ErrBufferFull:
|
||||
g.buffull = true
|
||||
} else if err == io.EOF {
|
||||
case io.EOF:
|
||||
return nil, nil
|
||||
} else {
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -132,11 +133,12 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int
|
|||
if bytes.Equal(g.next, []byte("commit\000")) {
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
if err == bufio.ErrBufferFull {
|
||||
switch err {
|
||||
case bufio.ErrBufferFull:
|
||||
g.buffull = true
|
||||
} else if err == io.EOF {
|
||||
case io.EOF:
|
||||
return nil, nil
|
||||
} else {
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +171,7 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int
|
|||
}
|
||||
}
|
||||
|
||||
if err == io.EOF || !(g.next[0] == '\n' || g.next[0] == '\000') {
|
||||
if err == io.EOF || (g.next[0] != '\n' && g.next[0] != '\000') {
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
|
@ -214,11 +216,12 @@ diffloop:
|
|||
}
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
if err == bufio.ErrBufferFull {
|
||||
switch err {
|
||||
case bufio.ErrBufferFull:
|
||||
g.buffull = true
|
||||
} else if err == io.EOF {
|
||||
case io.EOF:
|
||||
return &ret, nil
|
||||
} else {
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestParseTreeEntriesLong(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Len(t, entries, len(testCase.Expected))
|
||||
for i, entry := range entries {
|
||||
assert.EqualValues(t, testCase.Expected[i], entry)
|
||||
assert.Equal(t, testCase.Expected[i], entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func TestParseTreeEntriesShort(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Len(t, entries, len(testCase.Expected))
|
||||
for i, entry := range entries {
|
||||
assert.EqualValues(t, testCase.Expected[i], entry)
|
||||
assert.Equal(t, testCase.Expected[i], entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ func TestToAndFromMap(t *testing.T) {
|
|||
options.Parse(fmt.Sprintf("%v", RepoPrivate))
|
||||
actual := options.Map()
|
||||
expected := map[string]string{string(RepoPrivate): "true"}
|
||||
assert.EqualValues(t, expected, actual)
|
||||
assert.EqualValues(t, expected, NewFromMap(&actual).Map())
|
||||
assert.Equal(t, expected, actual)
|
||||
assert.Equal(t, expected, NewFromMap(&actual).Map())
|
||||
}
|
||||
|
||||
func TestChangeRepositorySettings(t *testing.T) {
|
||||
|
@ -46,7 +46,7 @@ func TestParse(t *testing.T) {
|
|||
|
||||
val, ok := options.GetString(RepoPrivate)
|
||||
assert.False(t, ok)
|
||||
assert.Equal(t, "", val)
|
||||
assert.Empty(t, val)
|
||||
|
||||
assert.True(t, options.GetBool(RepoPrivate, true))
|
||||
assert.False(t, options.GetBool(RepoPrivate, false))
|
||||
|
|
|
@ -101,7 +101,7 @@ func TestGitAttributeBareNonBare(t *testing.T) {
|
|||
cloneStats, err := gitRepo.GitAttributes(commitID, "i-am-a-python.p", LinguistAttributes...)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, cloneStats, bareStats)
|
||||
assert.Equal(t, cloneStats, bareStats)
|
||||
refStats := cloneStats
|
||||
|
||||
t.Run("GitAttributeChecker/"+commitID+"/SupportBare", func(t *testing.T) {
|
||||
|
@ -111,7 +111,7 @@ func TestGitAttributeBareNonBare(t *testing.T) {
|
|||
|
||||
bareStats, err := bareChecker.CheckPath("i-am-a-python.p")
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, refStats, bareStats)
|
||||
assert.Equal(t, refStats, bareStats)
|
||||
})
|
||||
t.Run("GitAttributeChecker/"+commitID+"/NoBareSupport", func(t *testing.T) {
|
||||
defer test.MockVariableValue(&SupportCheckAttrOnBare, false)()
|
||||
|
@ -122,7 +122,7 @@ func TestGitAttributeBareNonBare(t *testing.T) {
|
|||
cloneStats, err := cloneChecker.CheckPath("i-am-a-python.p")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, refStats, cloneStats)
|
||||
assert.Equal(t, refStats, cloneStats)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func TestGitAttributes(t *testing.T) {
|
|||
|
||||
attr, err := gitRepo.GitAttributes("8fee858da5796dfb37704761701bb8e800ad9ef3", "i-am-a-python.p", LinguistAttributes...)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, map[string]GitAttribute{
|
||||
assert.Equal(t, map[string]GitAttribute{
|
||||
"gitlab-language": "unspecified",
|
||||
"linguist-detectable": "unspecified",
|
||||
"linguist-documentation": "unspecified",
|
||||
|
@ -146,7 +146,7 @@ func TestGitAttributes(t *testing.T) {
|
|||
|
||||
attr, err = gitRepo.GitAttributes("341fca5b5ea3de596dc483e54c2db28633cd2f97", "i-am-a-python.p", LinguistAttributes...)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, map[string]GitAttribute{
|
||||
assert.Equal(t, map[string]GitAttribute{
|
||||
"gitlab-language": "unspecified",
|
||||
"linguist-detectable": "unspecified",
|
||||
"linguist-documentation": "unspecified",
|
||||
|
@ -177,13 +177,13 @@ func TestGitAttributeFirst(t *testing.T) {
|
|||
t.Run("none is specified", func(t *testing.T) {
|
||||
language, err := gitRepo.GitAttributeFirst("8fee858da5796dfb37704761701bb8e800ad9ef3", "i-am-a-python.p", "linguist-detectable", "gitlab-language", "non-existing")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", language.String())
|
||||
assert.Empty(t, language.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestGitAttributeStruct(t *testing.T) {
|
||||
assert.Equal(t, "", GitAttribute("").String())
|
||||
assert.Equal(t, "", GitAttribute("unspecified").String())
|
||||
assert.Empty(t, GitAttribute("").String())
|
||||
assert.Empty(t, GitAttribute("unspecified").String())
|
||||
|
||||
assert.Equal(t, "python", GitAttribute("python").String())
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestCatFileBatch(t *testing.T) {
|
|||
sha, typ, size, err := ReadBatchLine(r)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "commit", typ)
|
||||
assert.EqualValues(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
|
||||
assert.Equal(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
|
||||
assert.EqualValues(t, 144, size)
|
||||
})
|
||||
|
||||
|
@ -60,7 +60,7 @@ func TestCatFileBatch(t *testing.T) {
|
|||
sha, typ, size, err := ReadBatchLine(r)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "commit", typ)
|
||||
assert.EqualValues(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
|
||||
assert.Equal(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
|
||||
assert.EqualValues(t, 144, size)
|
||||
})
|
||||
|
||||
|
@ -120,7 +120,7 @@ func TestCatFileBatchCheck(t *testing.T) {
|
|||
sha, typ, size, err := ReadBatchLine(r)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "tag", typ)
|
||||
assert.EqualValues(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
|
||||
assert.Equal(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
|
||||
assert.EqualValues(t, 807, size)
|
||||
})
|
||||
|
||||
|
@ -135,7 +135,7 @@ func TestCatFileBatchCheck(t *testing.T) {
|
|||
sha, typ, size, err := ReadBatchLine(r)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "tag", typ)
|
||||
assert.EqualValues(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
|
||||
assert.Equal(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
|
||||
assert.EqualValues(t, 807, size)
|
||||
})
|
||||
|
||||
|
|
|
@ -21,21 +21,21 @@ func TestRepository_GetBranches(t *testing.T) {
|
|||
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, branches, 2)
|
||||
assert.EqualValues(t, 3, countAll)
|
||||
assert.Equal(t, 3, countAll)
|
||||
assert.ElementsMatch(t, []string{"master", "branch2"}, branches)
|
||||
|
||||
branches, countAll, err = bareRepo1.GetBranchNames(0, 0)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, branches, 3)
|
||||
assert.EqualValues(t, 3, countAll)
|
||||
assert.Equal(t, 3, countAll)
|
||||
assert.ElementsMatch(t, []string{"master", "branch2", "branch1"}, branches)
|
||||
|
||||
branches, countAll, err = bareRepo1.GetBranchNames(5, 1)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, branches)
|
||||
assert.EqualValues(t, 3, countAll)
|
||||
assert.Equal(t, 3, countAll)
|
||||
assert.ElementsMatch(t, []string{}, branches)
|
||||
}
|
||||
|
||||
|
@ -71,15 +71,15 @@ func TestGetRefsBySha(t *testing.T) {
|
|||
// refs/pull/1/head
|
||||
branches, err = bareRepo5.GetRefsBySha("c83380d7056593c51a699d12b9c00627bd5743e9", PullPrefix)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"refs/pull/1/head"}, branches)
|
||||
assert.Equal(t, []string{"refs/pull/1/head"}, branches)
|
||||
|
||||
branches, err = bareRepo5.GetRefsBySha("d8e0bbb45f200e67d9a784ce55bd90821af45ebd", BranchPrefix)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"refs/heads/master", "refs/heads/master-clone"}, branches)
|
||||
assert.Equal(t, []string{"refs/heads/master", "refs/heads/master-clone"}, branches)
|
||||
|
||||
branches, err = bareRepo5.GetRefsBySha("58a4bcc53ac13e7ff76127e0fb518b5262bf09af", BranchPrefix)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []string{"refs/heads/test-patch-1"}, branches)
|
||||
assert.Equal(t, []string{"refs/heads/test-patch-1"}, branches)
|
||||
}
|
||||
|
||||
func BenchmarkGetRefsBySha(b *testing.B) {
|
||||
|
|
|
@ -127,19 +127,19 @@ func TestGetTagCommit(t *testing.T) {
|
|||
|
||||
aTagID, err := bareRepo1.GetTagCommitID(aTagName)
|
||||
require.NoError(t, err)
|
||||
assert.NotEqualValues(t, aTagCommitID, aTagID)
|
||||
assert.NotEqual(t, aTagCommitID, aTagID)
|
||||
|
||||
lTagID, err := bareRepo1.GetTagCommitID(lTagName)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, lTagCommitID, lTagID)
|
||||
assert.Equal(t, lTagCommitID, lTagID)
|
||||
|
||||
aTag, err := bareRepo1.GetTagCommit(aTagName)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, aTagCommitID, aTag.ID.String())
|
||||
assert.Equal(t, aTagCommitID, aTag.ID.String())
|
||||
|
||||
lTag, err := bareRepo1.GetTagCommit(lTagName)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
|
||||
assert.Equal(t, lTagCommitID, lTag.ID.String())
|
||||
}
|
||||
|
||||
func TestCommitsByRange(t *testing.T) {
|
||||
|
|
|
@ -234,7 +234,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
|||
sizes[language] += f.Size()
|
||||
} else if len(sizes) == 0 && (firstExcludedLanguage == "" || firstExcludedLanguage == language) {
|
||||
// Only consider Programming or Markup languages as fallback
|
||||
if !(langType == enry.Programming || langType == enry.Markup) {
|
||||
if langType != enry.Programming && langType != enry.Markup {
|
||||
continue
|
||||
}
|
||||
firstExcludedLanguage = language
|
||||
|
|
|
@ -21,14 +21,14 @@ func TestRepository_GetLanguageStats(t *testing.T) {
|
|||
stats, err := gitRepo.GetLanguageStats("8fee858da5796dfb37704761701bb8e800ad9ef3")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, map[string]int64{
|
||||
assert.Equal(t, map[string]int64{
|
||||
"Python": 134,
|
||||
"Java": 112,
|
||||
}, stats)
|
||||
}
|
||||
|
||||
func TestMergeLanguageStats(t *testing.T) {
|
||||
assert.EqualValues(t, map[string]int64{
|
||||
assert.Equal(t, map[string]int64{
|
||||
"PHP": 1,
|
||||
"python": 10,
|
||||
"JAVA": 700,
|
||||
|
|
|
@ -22,11 +22,12 @@ func (repo *Repository) GetRefs() ([]*Reference, error) {
|
|||
// refType should only be a literal "branch" or "tag" and nothing else
|
||||
func (repo *Repository) ListOccurrences(ctx context.Context, refType, commitSHA string) ([]string, error) {
|
||||
cmd := NewCommand(ctx)
|
||||
if refType == "branch" {
|
||||
switch refType {
|
||||
case "branch":
|
||||
cmd.AddArguments("branch")
|
||||
} else if refType == "tag" {
|
||||
case "tag":
|
||||
cmd.AddArguments("tag")
|
||||
} else {
|
||||
default:
|
||||
return nil, util.NewInvalidArgumentErrorf(`can only use "branch" or "tag" for refType, but got %q`, refType)
|
||||
}
|
||||
stdout, _, err := cmd.AddArguments("--no-color", "--sort=-creatordate", "--contains").AddDynamicArguments(commitSHA).RunStdString(&RunOpts{Dir: repo.Path})
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestRepository_GetCodeActivityStats(t *testing.T) {
|
|||
assert.EqualValues(t, 10, code.Additions)
|
||||
assert.EqualValues(t, 1, code.Deletions)
|
||||
assert.Len(t, code.Authors, 3)
|
||||
assert.EqualValues(t, "tris.git@shoddynet.org", code.Authors[1].Email)
|
||||
assert.Equal(t, "tris.git@shoddynet.org", code.Authors[1].Email)
|
||||
assert.EqualValues(t, 3, code.Authors[1].Commits)
|
||||
assert.EqualValues(t, 5, code.Authors[0].Commits)
|
||||
}
|
||||
|
|
|
@ -28,30 +28,24 @@ func TestRepository_GetTags(t *testing.T) {
|
|||
}
|
||||
assert.Len(t, tags, 2)
|
||||
assert.Len(t, tags, total)
|
||||
assert.EqualValues(t, "signed-tag", tags[0].Name)
|
||||
assert.EqualValues(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
|
||||
assert.EqualValues(t, "tag", tags[0].Type)
|
||||
assert.EqualValues(t, time.Date(2022, time.November, 13, 16, 40, 20, 0, time.FixedZone("", 3600)), tags[0].Tagger.When)
|
||||
assert.EqualValues(t, "test", tags[1].Name)
|
||||
assert.EqualValues(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[1].ID.String())
|
||||
assert.EqualValues(t, "tag", tags[1].Type)
|
||||
assert.EqualValues(t, time.Date(2018, time.June, 16, 20, 13, 18, 0, time.FixedZone("", -25200)), tags[1].Tagger.When)
|
||||
assert.Equal(t, "signed-tag", tags[0].Name)
|
||||
assert.Equal(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
|
||||
assert.Equal(t, "tag", tags[0].Type)
|
||||
assert.Equal(t, time.Date(2022, time.November, 13, 16, 40, 20, 0, time.FixedZone("", 3600)), tags[0].Tagger.When)
|
||||
assert.Equal(t, "test", tags[1].Name)
|
||||
assert.Equal(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[1].ID.String())
|
||||
assert.Equal(t, "tag", tags[1].Type)
|
||||
assert.Equal(t, time.Date(2018, time.June, 16, 20, 13, 18, 0, time.FixedZone("", -25200)), tags[1].Tagger.When)
|
||||
}
|
||||
|
||||
func TestRepository_GetTag(t *testing.T) {
|
||||
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
|
||||
|
||||
clonedPath, err := cloneRepo(t, bareRepo1Path)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
bareRepo1, err := openRepositoryWithDefaultContext(clonedPath)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
defer bareRepo1.Close()
|
||||
|
||||
// LIGHTWEIGHT TAGS
|
||||
|
@ -60,25 +54,16 @@ func TestRepository_GetTag(t *testing.T) {
|
|||
|
||||
// Create the lightweight tag
|
||||
err = bareRepo1.CreateTag(lTagName, lTagCommitID)
|
||||
if err != nil {
|
||||
require.NoError(t, err, "Unable to create the lightweight tag: %s for ID: %s. Error: %v", lTagName, lTagCommitID, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err, "Unable to create the lightweight tag: %s for ID: %s. Error: %v", lTagName, lTagCommitID, err)
|
||||
|
||||
// and try to get the Tag for lightweight tag
|
||||
lTag, err := bareRepo1.GetTag(lTagName)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
if lTag == nil {
|
||||
assert.NotNil(t, lTag)
|
||||
assert.FailNow(t, "nil lTag: %s", lTagName)
|
||||
}
|
||||
assert.EqualValues(t, lTagName, lTag.Name)
|
||||
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
|
||||
assert.EqualValues(t, lTagCommitID, lTag.Object.String())
|
||||
assert.EqualValues(t, "commit", lTag.Type)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, lTag)
|
||||
assert.Equal(t, lTagName, lTag.Name)
|
||||
assert.Equal(t, lTagCommitID, lTag.ID.String())
|
||||
assert.Equal(t, lTagCommitID, lTag.Object.String())
|
||||
assert.Equal(t, "commit", lTag.Type)
|
||||
|
||||
// ANNOTATED TAGS
|
||||
aTagCommitID := "8006ff9adbf0cb94da7dad9e537e53817f9fa5c0"
|
||||
|
@ -87,32 +72,20 @@ func TestRepository_GetTag(t *testing.T) {
|
|||
|
||||
// Create the annotated tag
|
||||
err = bareRepo1.CreateAnnotatedTag(aTagName, aTagMessage, aTagCommitID)
|
||||
if err != nil {
|
||||
require.NoError(t, err, "Unable to create the annotated tag: %s for ID: %s. Error: %v", aTagName, aTagCommitID, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err, "Unable to create the annotated tag: %s for ID: %s. Error: %v", aTagName, aTagCommitID, err)
|
||||
|
||||
// Now try to get the tag for the annotated Tag
|
||||
aTagID, err := bareRepo1.GetTagID(aTagName)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
aTag, err := bareRepo1.GetTag(aTagName)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
if aTag == nil {
|
||||
assert.NotNil(t, aTag)
|
||||
assert.FailNow(t, "nil aTag: %s", aTagName)
|
||||
}
|
||||
assert.EqualValues(t, aTagName, aTag.Name)
|
||||
assert.EqualValues(t, aTagID, aTag.ID.String())
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, aTag)
|
||||
assert.Equal(t, aTagName, aTag.Name)
|
||||
assert.Equal(t, aTagID, aTag.ID.String())
|
||||
assert.NotEqual(t, aTagID, aTag.Object.String())
|
||||
assert.EqualValues(t, aTagCommitID, aTag.Object.String())
|
||||
assert.EqualValues(t, "tag", aTag.Type)
|
||||
assert.Equal(t, aTagCommitID, aTag.Object.String())
|
||||
assert.Equal(t, "tag", aTag.Type)
|
||||
|
||||
// RELEASE TAGS
|
||||
|
||||
|
@ -120,24 +93,15 @@ func TestRepository_GetTag(t *testing.T) {
|
|||
rTagName := "release/" + lTagName
|
||||
|
||||
err = bareRepo1.CreateTag(rTagName, rTagCommitID)
|
||||
if err != nil {
|
||||
require.NoError(t, err, "Unable to create the tag: %s for ID: %s. Error: %v", rTagName, rTagCommitID, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err, "Unable to create the tag: %s for ID: %s. Error: %v", rTagName, rTagCommitID, err)
|
||||
|
||||
rTagID, err := bareRepo1.GetTagID(rTagName)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
assert.EqualValues(t, rTagCommitID, rTagID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, rTagCommitID, rTagID)
|
||||
|
||||
oTagID, err := bareRepo1.GetTagID(lTagName)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
assert.EqualValues(t, lTagCommitID, oTagID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, lTagCommitID, oTagID)
|
||||
}
|
||||
|
||||
func TestRepository_GetAnnotatedTag(t *testing.T) {
|
||||
|
@ -173,9 +137,9 @@ func TestRepository_GetAnnotatedTag(t *testing.T) {
|
|||
return
|
||||
}
|
||||
assert.NotNil(t, tag)
|
||||
assert.EqualValues(t, aTagName, tag.Name)
|
||||
assert.EqualValues(t, aTagID, tag.ID.String())
|
||||
assert.EqualValues(t, "tag", tag.Type)
|
||||
assert.Equal(t, aTagName, tag.Name)
|
||||
assert.Equal(t, aTagID, tag.ID.String())
|
||||
assert.Equal(t, "tag", tag.Type)
|
||||
|
||||
// Annotated tag's Commit ID should fail
|
||||
tag2, err := bareRepo1.GetAnnotatedTag(aTagCommitID)
|
||||
|
|
|
@ -97,7 +97,7 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
commit.Tree.ResolvedID = resolvedID
|
||||
commit.ResolvedID = resolvedID
|
||||
return &commit.Tree, nil
|
||||
case "commit":
|
||||
commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size))
|
||||
|
@ -107,7 +107,7 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
|
|||
if _, err := rd.Discard(1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
commit.Tree.ResolvedID = commit.ID
|
||||
commit.ResolvedID = commit.ID
|
||||
return &commit.Tree, nil
|
||||
case "tree":
|
||||
tree := NewTree(repo, id)
|
||||
|
|
|
@ -42,6 +42,6 @@ func TestParseSignatureFromCommitLine(t *testing.T) {
|
|||
}
|
||||
for _, test := range tests {
|
||||
got := parseSignatureFromCommitLine(test.line)
|
||||
assert.EqualValues(t, test.want, got)
|
||||
assert.Equal(t, test.want, got)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ func TestGetRefURL(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, kase := range kases {
|
||||
assert.EqualValues(t, kase.expect, getRefURL(kase.refURL, kase.prefixURL, kase.parentPath, kase.SSHDomain))
|
||||
assert.Equal(t, kase.expect, getRefURL(kase.refURL, kase.prefixURL, kase.parentPath, kase.SSHDomain))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,21 +87,21 @@ v0
|
|||
for _, test := range testData {
|
||||
tag, err := parseTagData(Sha1ObjectFormat, test.data)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, test.tag.ID, tag.ID)
|
||||
assert.EqualValues(t, test.tag.Object, tag.Object)
|
||||
assert.EqualValues(t, test.tag.Name, tag.Name)
|
||||
assert.EqualValues(t, test.tag.Message, tag.Message)
|
||||
assert.EqualValues(t, test.tag.Type, tag.Type)
|
||||
assert.Equal(t, test.tag.ID, tag.ID)
|
||||
assert.Equal(t, test.tag.Object, tag.Object)
|
||||
assert.Equal(t, test.tag.Name, tag.Name)
|
||||
assert.Equal(t, test.tag.Message, tag.Message)
|
||||
assert.Equal(t, test.tag.Type, tag.Type)
|
||||
if test.tag.Signature != nil && assert.NotNil(t, tag.Signature) {
|
||||
assert.EqualValues(t, test.tag.Signature.Signature, tag.Signature.Signature)
|
||||
assert.EqualValues(t, test.tag.Signature.Payload, tag.Signature.Payload)
|
||||
assert.Equal(t, test.tag.Signature.Signature, tag.Signature.Signature)
|
||||
assert.Equal(t, test.tag.Signature.Payload, tag.Signature.Payload)
|
||||
} else {
|
||||
assert.Nil(t, tag.Signature)
|
||||
}
|
||||
if test.tag.Tagger != nil && assert.NotNil(t, tag.Tagger) {
|
||||
assert.EqualValues(t, test.tag.Tagger.Name, tag.Tagger.Name)
|
||||
assert.EqualValues(t, test.tag.Tagger.Email, tag.Tagger.Email)
|
||||
assert.EqualValues(t, test.tag.Tagger.When.Unix(), tag.Tagger.When.Unix())
|
||||
assert.Equal(t, test.tag.Tagger.Name, tag.Tagger.Name)
|
||||
assert.Equal(t, test.tag.Tagger.Email, tag.Tagger.Email)
|
||||
assert.Equal(t, test.tag.Tagger.When.Unix(), tag.Tagger.When.Unix())
|
||||
} else {
|
||||
assert.Nil(t, tag.Tagger)
|
||||
}
|
||||
|
|
|
@ -34,10 +34,10 @@ func Test_GetTreePathLatestCommit(t *testing.T) {
|
|||
|
||||
commitID, err := repo.GetBranchCommitID("master")
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
|
||||
assert.Equal(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
|
||||
|
||||
commit, err := repo.GetTreePathLatestCommit("master", "blame.txt")
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, commit)
|
||||
assert.EqualValues(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())
|
||||
assert.Equal(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())
|
||||
}
|
||||
|
|
|
@ -160,8 +160,8 @@ func TestParseGitURLs(t *testing.T) {
|
|||
t.Run(kase.kase, func(t *testing.T) {
|
||||
u, err := Parse(kase.kase)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, kase.expected.extraMark, u.extraMark)
|
||||
assert.EqualValues(t, *kase.expected, *u)
|
||||
assert.Equal(t, kase.expected.extraMark, u.extraMark)
|
||||
assert.Equal(t, *kase.expected, *u)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,14 @@ func TestManager(t *testing.T) {
|
|||
_ = m.Register(t3)
|
||||
|
||||
require.NoError(t, m.ReleaseReopen())
|
||||
assert.EqualValues(t, 1, t1.count)
|
||||
assert.EqualValues(t, 1, t2.count)
|
||||
assert.EqualValues(t, 1, t3.count)
|
||||
assert.Equal(t, 1, t1.count)
|
||||
assert.Equal(t, 1, t2.count)
|
||||
assert.Equal(t, 1, t3.count)
|
||||
|
||||
c2()
|
||||
|
||||
require.NoError(t, m.ReleaseReopen())
|
||||
assert.EqualValues(t, 2, t1.count)
|
||||
assert.EqualValues(t, 1, t2.count)
|
||||
assert.EqualValues(t, 2, t3.count)
|
||||
assert.Equal(t, 2, t1.count)
|
||||
assert.Equal(t, 1, t2.count)
|
||||
assert.Equal(t, 2, t3.count)
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ func (w *wrappedConn) Write(p []byte) (n int, err error) {
|
|||
if minDeadline.After(w.deadline) {
|
||||
w.deadline = minDeadline
|
||||
}
|
||||
_ = w.Conn.SetWriteDeadline(w.deadline)
|
||||
_ = w.SetWriteDeadline(w.deadline)
|
||||
}
|
||||
return w.Conn.Write(p)
|
||||
}
|
||||
|
|
|
@ -61,10 +61,7 @@ func (srv *Server) doHammer() {
|
|||
return
|
||||
}
|
||||
log.Warn("Forcefully shutting down parent")
|
||||
for {
|
||||
if srv.getState() == stateTerminate {
|
||||
break
|
||||
}
|
||||
for srv.getState() != stateTerminate {
|
||||
srv.wg.Done()
|
||||
|
||||
// Give other goroutines a chance to finish before we forcibly stop them.
|
||||
|
|
|
@ -133,7 +133,7 @@ c=2
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
out, lexerName, err := File(tt.name, "", []byte(tt.code))
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tt.want, out)
|
||||
assert.Equal(t, tt.want, out)
|
||||
assert.Equal(t, tt.lexerName, lexerName)
|
||||
})
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ c=2`),
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
out := PlainText([]byte(tt.code))
|
||||
assert.EqualValues(t, tt.want, out)
|
||||
assert.Equal(t, tt.want, out)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ import (
|
|||
|
||||
func TestIndexPos(t *testing.T) {
|
||||
startIdx, endIdx := indexPos("test index start and end", "start", "end")
|
||||
assert.EqualValues(t, 11, startIdx)
|
||||
assert.EqualValues(t, 24, endIdx)
|
||||
assert.Equal(t, 11, startIdx)
|
||||
assert.Equal(t, 24, endIdx)
|
||||
}
|
||||
|
|
|
@ -110,9 +110,9 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
|
|||
ids := make([]int64, 0, len(res))
|
||||
for _, hit := range res {
|
||||
ids = append(ids, hit.RepoID)
|
||||
assert.EqualValues(t, "# repo1\n\nDescription for repo1", hit.Content)
|
||||
assert.Equal(t, "# repo1\n\nDescription for repo1", hit.Content)
|
||||
}
|
||||
assert.EqualValues(t, kw.IDs, ids)
|
||||
assert.Equal(t, kw.IDs, ids)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ func TestBleveIndexAndSearch(t *testing.T) {
|
|||
if idx != nil {
|
||||
idx.Close()
|
||||
}
|
||||
assert.FailNow(t, "Unable to create bleve indexer Error: %v", err)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
defer idx.Close()
|
||||
|
||||
|
@ -152,7 +152,7 @@ func TestESIndexAndSearch(t *testing.T) {
|
|||
if indexer != nil {
|
||||
indexer.Close()
|
||||
}
|
||||
assert.FailNow(t, "Unable to init ES indexer Error: %v", err)
|
||||
assert.FailNow(t, "Unable to init ES indexer", "error: %v", err)
|
||||
}
|
||||
|
||||
defer indexer.Close()
|
||||
|
|
|
@ -24,5 +24,5 @@ func TestMetadata(t *testing.T) {
|
|||
|
||||
meta, err = readIndexMetadata(dir)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 24, meta.Version)
|
||||
assert.Equal(t, 24, meta.Version)
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ var cases = []*testIndexerCase{
|
|||
Name: "default",
|
||||
SearchOptions: &internal.SearchOptions{},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
},
|
||||
},
|
||||
|
@ -557,7 +557,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByCreatedDesc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -573,7 +573,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByUpdatedDesc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -589,7 +589,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByCommentsDesc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -605,7 +605,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByDeadlineDesc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -621,7 +621,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByScore,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -637,7 +637,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByCreatedAsc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -653,7 +653,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByUpdatedAsc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -669,7 +669,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByCommentsAsc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
@ -685,7 +685,7 @@ var cases = []*testIndexerCase{
|
|||
SortBy: internal.SortByDeadlineAsc,
|
||||
},
|
||||
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Equal(t, len(data), len(result.Hits))
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
for i, v := range result.Hits {
|
||||
if i < len(result.Hits)-1 {
|
||||
|
|
|
@ -85,13 +85,13 @@ func TestConvertHits(t *testing.T) {
|
|||
}
|
||||
hits, err := convertHits(validResponse)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, []internal.Match{{ID: 11}, {ID: 22}, {ID: 33}}, hits)
|
||||
assert.Equal(t, []internal.Match{{ID: 11}, {ID: 22}, {ID: 33}}, hits)
|
||||
}
|
||||
|
||||
func TestDoubleQuoteKeyword(t *testing.T) {
|
||||
assert.EqualValues(t, "", doubleQuoteKeyword(""))
|
||||
assert.EqualValues(t, `"a" "b" "c"`, doubleQuoteKeyword("a b c"))
|
||||
assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
|
||||
assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
|
||||
assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword(`a "" "d" """g`))
|
||||
assert.Empty(t, doubleQuoteKeyword(""))
|
||||
assert.Equal(t, `"a" "b" "c"`, doubleQuoteKeyword("a b c"))
|
||||
assert.Equal(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
|
||||
assert.Equal(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
|
||||
assert.Equal(t, `"a" "d" "g"`, doubleQuoteKeyword(`a "" "d" """g`))
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ func validateOptions(field *api.IssueFormField, idx int) error {
|
|||
}
|
||||
for _, visibleType := range visibilityList {
|
||||
visibleType, ok := visibleType.(string)
|
||||
if !ok || !(visibleType == "form" || visibleType == "content") {
|
||||
if !ok || (visibleType != "form" && visibleType != "content") {
|
||||
return position.Errorf("'visible' list can only contain strings of 'form' and 'content'")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -902,7 +902,7 @@ Option 1 of dropdown, Option 2 of dropdown
|
|||
t.Fatal(err)
|
||||
}
|
||||
if got := RenderToMarkdown(template, tt.args.values); got != tt.want {
|
||||
assert.EqualValues(t, tt.want, got)
|
||||
assert.Equal(t, tt.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestKeying(t *testing.T) {
|
|||
cipherText2 := key.Encrypt(plainText, []byte{0x05, 0x06})
|
||||
|
||||
// Ensure ciphertexts don't have an deterministic output.
|
||||
assert.NotEqualValues(t, cipherText, cipherText2)
|
||||
assert.NotEqual(t, cipherText, cipherText2)
|
||||
})
|
||||
|
||||
t.Run("Decrypt", func(t *testing.T) {
|
||||
|
@ -59,7 +59,7 @@ func TestKeying(t *testing.T) {
|
|||
t.Run("Successful", func(t *testing.T) {
|
||||
convertedPlainText, err := key.Decrypt(cipherText, []byte{0x05, 0x06})
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, plainText, convertedPlainText)
|
||||
assert.Equal(t, plainText, convertedPlainText)
|
||||
})
|
||||
|
||||
t.Run("Not enough additional data", func(t *testing.T) {
|
||||
|
@ -97,15 +97,15 @@ func TestKeying(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKeyingColumnAndID(t *testing.T) {
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", math.MinInt64))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", -1))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", 0))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table", 1))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", math.MaxInt64))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", math.MinInt64))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", -1))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", 0))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table", 1))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", math.MaxInt64))
|
||||
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", math.MinInt64))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", -1))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", 0))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table2", 1))
|
||||
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", math.MaxInt64))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", math.MinInt64))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", -1))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", 0))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table2", 1))
|
||||
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", math.MaxInt64))
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ func (s *ContentStore) Put(pointer Pointer, r io.Reader) error {
|
|||
|
||||
// Exists returns true if the object exists in the content store.
|
||||
func (s *ContentStore) Exists(pointer Pointer) (bool, error) {
|
||||
_, err := s.ObjectStorage.Stat(pointer.RelativePath())
|
||||
_, err := s.Stat(pointer.RelativePath())
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
|
@ -92,7 +92,7 @@ func (s *ContentStore) Exists(pointer Pointer) (bool, error) {
|
|||
// Verify returns true if the object exists in the content store and size is correct.
|
||||
func (s *ContentStore) Verify(pointer Pointer) (bool, error) {
|
||||
p := pointer.RelativePath()
|
||||
fi, err := s.ObjectStorage.Stat(p)
|
||||
fi, err := s.Stat(p)
|
||||
if os.IsNotExist(err) || (err == nil && fi.Size() != pointer.Size) {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
|
|
|
@ -105,7 +105,7 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) {
|
|||
case io.WriterTo:
|
||||
_, err = msg.WriteTo(b.OutputWriteCloser)
|
||||
default:
|
||||
_, err = b.OutputWriteCloser.Write([]byte(fmt.Sprint(msg)))
|
||||
_, err = fmt.Fprint(b.OutputWriteCloser, msg)
|
||||
}
|
||||
if err != nil {
|
||||
FallbackErrorf("unable to write log message of %q (%v): %v", b.Name, err, event.Msg)
|
||||
|
|
|
@ -13,19 +13,19 @@ import (
|
|||
)
|
||||
|
||||
func TestFlags(t *testing.T) {
|
||||
assert.EqualValues(t, Ldefault, Flags{}.Bits())
|
||||
assert.Equal(t, Ldefault, Flags{}.Bits())
|
||||
assert.EqualValues(t, 0, FlagsFromString("").Bits())
|
||||
assert.EqualValues(t, Lgopid, FlagsFromString("", Lgopid).Bits())
|
||||
assert.Equal(t, Lgopid, FlagsFromString("", Lgopid).Bits())
|
||||
assert.EqualValues(t, 0, FlagsFromString("none", Lgopid).Bits())
|
||||
assert.EqualValues(t, Ldate|Ltime, FlagsFromString("date,time", Lgopid).Bits())
|
||||
assert.Equal(t, Ldate|Ltime, FlagsFromString("date,time", Lgopid).Bits())
|
||||
|
||||
assert.EqualValues(t, "stdflags", FlagsFromString("stdflags").String())
|
||||
assert.EqualValues(t, "medfile", FlagsFromString("medfile").String())
|
||||
assert.Equal(t, "stdflags", FlagsFromString("stdflags").String())
|
||||
assert.Equal(t, "medfile", FlagsFromString("medfile").String())
|
||||
|
||||
bs, err := json.Marshal(FlagsFromString("utc,level"))
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, `"level,utc"`, string(bs))
|
||||
assert.Equal(t, `"level,utc"`, string(bs))
|
||||
var flags Flags
|
||||
require.NoError(t, json.Unmarshal(bs, &flags))
|
||||
assert.EqualValues(t, LUTC|Llevel, flags.Bits())
|
||||
assert.Equal(t, LUTC|Llevel, flags.Bits())
|
||||
}
|
||||
|
|
|
@ -15,18 +15,18 @@ func Test_getGoroutineLabels(t *testing.T) {
|
|||
pprof.Do(t.Context(), pprof.Labels(), func(ctx context.Context) {
|
||||
currentLabels := getGoroutineLabels()
|
||||
pprof.ForLabels(ctx, func(key, value string) bool {
|
||||
assert.EqualValues(t, value, currentLabels[key])
|
||||
assert.Equal(t, value, currentLabels[key])
|
||||
return true
|
||||
})
|
||||
|
||||
pprof.Do(ctx, pprof.Labels("Test_getGoroutineLabels", "Test_getGoroutineLabels_child1"), func(ctx context.Context) {
|
||||
currentLabels := getGoroutineLabels()
|
||||
pprof.ForLabels(ctx, func(key, value string) bool {
|
||||
assert.EqualValues(t, value, currentLabels[key])
|
||||
assert.Equal(t, value, currentLabels[key])
|
||||
return true
|
||||
})
|
||||
if assert.NotNil(t, currentLabels) {
|
||||
assert.EqualValues(t, "Test_getGoroutineLabels_child1", currentLabels["Test_getGoroutineLabels"])
|
||||
assert.Equal(t, "Test_getGoroutineLabels_child1", currentLabels["Test_getGoroutineLabels"])
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -56,16 +56,16 @@ func TestLogger(t *testing.T) {
|
|||
|
||||
dump := logger.DumpWriters()
|
||||
assert.Empty(t, dump)
|
||||
assert.EqualValues(t, NONE, logger.GetLevel())
|
||||
assert.Equal(t, NONE, logger.GetLevel())
|
||||
assert.False(t, logger.IsEnabled())
|
||||
|
||||
w1 := newDummyWriter("dummy-1", DEBUG, 0)
|
||||
logger.AddWriters(w1)
|
||||
assert.EqualValues(t, DEBUG, logger.GetLevel())
|
||||
assert.Equal(t, DEBUG, logger.GetLevel())
|
||||
|
||||
w2 := newDummyWriter("dummy-2", WARN, 200*time.Millisecond)
|
||||
logger.AddWriters(w2)
|
||||
assert.EqualValues(t, DEBUG, logger.GetLevel())
|
||||
assert.Equal(t, DEBUG, logger.GetLevel())
|
||||
|
||||
dump = logger.DumpWriters()
|
||||
assert.Len(t, dump, 2)
|
||||
|
|
|
@ -459,7 +459,7 @@ func (r *FootnoteHTMLRenderer) renderFootnoteList(w util.BufWriter, source []byt
|
|||
html.RenderAttributes(w, node, html.GlobalAttributeFilter)
|
||||
}
|
||||
_ = w.WriteByte('>')
|
||||
if r.Config.XHTML {
|
||||
if r.XHTML {
|
||||
_, _ = w.WriteString("\n<hr />\n")
|
||||
} else {
|
||||
_, _ = w.WriteString("\n<hr>\n")
|
||||
|
|
|
@ -73,9 +73,10 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont
|
|||
} else if lastChar == ')' {
|
||||
closing := 0
|
||||
for i := m[1] - 1; i >= m[0]; i-- {
|
||||
if line[i] == ')' {
|
||||
switch line[i] {
|
||||
case ')':
|
||||
closing++
|
||||
} else if line[i] == '(' {
|
||||
case '(':
|
||||
closing--
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,6 @@ func TestRenderConsole(t *testing.T) {
|
|||
err := render.Render(&markup.RenderContext{Ctx: git.DefaultContext},
|
||||
strings.NewReader(k), &buf)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, v, buf.String())
|
||||
assert.Equal(t, v, buf.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,6 @@ func TestRenderCSV(t *testing.T) {
|
|||
err := render.Render(&markup.RenderContext{Ctx: git.DefaultContext},
|
||||
strings.NewReader(k), &buf)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, v, buf.String())
|
||||
assert.Equal(t, v, buf.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) {
|
|||
// Add user-content- to IDs and "#" links if they don't already have them
|
||||
for idx, attr := range node.Attr {
|
||||
val := strings.TrimPrefix(attr.Val, "#")
|
||||
notHasPrefix := !(strings.HasPrefix(val, "user-content-") || blackfridayExtRegex.MatchString(val))
|
||||
notHasPrefix := !strings.HasPrefix(val, "user-content-") && !blackfridayExtRegex.MatchString(val)
|
||||
|
||||
if attr.Key == "id" && notHasPrefix {
|
||||
node.Attr[idx].Val = "user-content-" + attr.Val
|
||||
|
|
|
@ -131,7 +131,7 @@ func (r *HTMLRenderer) renderDocument(w util.BufWriter, source []byte, node ast.
|
|||
if entering {
|
||||
_, err = w.WriteString("<div")
|
||||
if err == nil {
|
||||
_, err = w.WriteString(fmt.Sprintf(` lang=%q`, val))
|
||||
_, err = fmt.Fprintf(w, ` lang=%q`, val)
|
||||
}
|
||||
if err == nil {
|
||||
_, err = w.WriteRune('>')
|
||||
|
@ -203,7 +203,7 @@ func (r *HTMLRenderer) renderIcon(w util.BufWriter, source []byte, node ast.Node
|
|||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
||||
_, err := w.WriteString(fmt.Sprintf(`<i class="icon %s"></i>`, name))
|
||||
_, err := fmt.Fprintf(w, `<i class="icon %s"></i>`, name)
|
||||
if err != nil {
|
||||
return ast.WalkStop, err
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.
|
|||
suceedingCharacter := line[pos]
|
||||
// check valid ending character
|
||||
if !isPunctuation(suceedingCharacter) &&
|
||||
!(suceedingCharacter == ' ') &&
|
||||
!(suceedingCharacter == '\n') &&
|
||||
(suceedingCharacter != ' ') &&
|
||||
(suceedingCharacter != '\n') &&
|
||||
!isBracket(suceedingCharacter) {
|
||||
return nil
|
||||
}
|
||||
|
@ -139,12 +139,12 @@ func trimBlock(node *Inline, block text.Reader) {
|
|||
|
||||
// trim first space and last space
|
||||
first := node.FirstChild().(*ast.Text)
|
||||
if !(!first.Segment.IsEmpty() && block.Source()[first.Segment.Start] == ' ') {
|
||||
if first.Segment.IsEmpty() || block.Source()[first.Segment.Start] != ' ' {
|
||||
return
|
||||
}
|
||||
|
||||
last := node.LastChild().(*ast.Text)
|
||||
if !(!last.Segment.IsEmpty() && block.Source()[last.Segment.Stop-1] == ' ') {
|
||||
if last.Segment.IsEmpty() || block.Source()[last.Segment.Stop-1] != ' ' {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ func TestExtractMetadata(t *testing.T) {
|
|||
var meta IssueTemplate
|
||||
body, err := ExtractMetadata(fmt.Sprintf("%s\n%s\n%s", sepTest, frontTest, sepTest), &meta)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", body)
|
||||
assert.Empty(t, body)
|
||||
assert.Equal(t, metaTest, meta)
|
||||
assert.True(t, meta.Valid())
|
||||
})
|
||||
|
@ -86,7 +86,7 @@ func TestExtractMetadataBytes(t *testing.T) {
|
|||
var meta IssueTemplate
|
||||
body, err := ExtractMetadataBytes([]byte(fmt.Sprintf("%s\n%s\n%s", sepTest, frontTest, sepTest)), &meta)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "", string(body))
|
||||
assert.Empty(t, string(body))
|
||||
assert.Equal(t, metaTest, meta)
|
||||
assert.True(t, meta.Valid())
|
||||
})
|
||||
|
|
|
@ -40,7 +40,7 @@ func (r *HTMLRenderer) renderCodeSpan(w util.BufWriter, source []byte, n ast.Nod
|
|||
r.Writer.RawWrite(w, value)
|
||||
}
|
||||
case *ColorPreview:
|
||||
_, _ = w.WriteString(fmt.Sprintf(`<span class="color-preview" style="background-color: %v"></span>`, string(v.Color)))
|
||||
_, _ = fmt.Fprintf(w, `<span class="color-preview" style="background-color: %v"></span>`, string(v.Color))
|
||||
}
|
||||
}
|
||||
return ast.WalkSkipChildren, nil
|
||||
|
|
|
@ -107,11 +107,12 @@ func (r *stripRenderer) processAutoLink(w io.Writer, link []byte) {
|
|||
}
|
||||
|
||||
var sep string
|
||||
if parts[3] == "issues" {
|
||||
switch parts[3] {
|
||||
case "issues":
|
||||
sep = "#"
|
||||
} else if parts[3] == "pulls" {
|
||||
case "pulls":
|
||||
sep = "!"
|
||||
} else {
|
||||
default:
|
||||
// Process out of band
|
||||
r.links = append(r.links, linkStr)
|
||||
return
|
||||
|
|
|
@ -79,7 +79,7 @@ A HIDDEN ` + "`" + `GHOST` + "`" + ` IN THIS LINE.
|
|||
lines = append(lines, line)
|
||||
}
|
||||
}
|
||||
assert.EqualValues(t, test.expectedText, lines)
|
||||
assert.EqualValues(t, test.expectedLinks, links)
|
||||
assert.Equal(t, test.expectedText, lines)
|
||||
assert.Equal(t, test.expectedLinks, links)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,11 +52,11 @@ func TestOptionalToJson(t *testing.T) {
|
|||
t.Run(tc.name, func(t *testing.T) {
|
||||
b, err := json.Marshal(tc.obj)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tc.want, string(b), "gitea json module returned unexpected")
|
||||
assert.Equal(t, tc.want, string(b), "gitea json module returned unexpected")
|
||||
|
||||
b, err = std_json.Marshal(tc.obj)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tc.want, string(b), "std json module returned unexpected")
|
||||
assert.Equal(t, tc.want, string(b), "std json module returned unexpected")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ func TestOptionalFromJson(t *testing.T) {
|
|||
var obj1 testSerializationStruct
|
||||
err := json.Unmarshal([]byte(tc.data), &obj1)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tc.want, obj1, "gitea json module returned unexpected")
|
||||
assert.Equal(t, tc.want, obj1, "gitea json module returned unexpected")
|
||||
|
||||
var obj2 testSerializationStruct
|
||||
err = std_json.Unmarshal([]byte(tc.data), &obj2)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tc.want, obj2, "std json module returned unexpected")
|
||||
assert.Equal(t, tc.want, obj2, "std json module returned unexpected")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ optional_two_string: null
|
|||
t.Run(tc.name, func(t *testing.T) {
|
||||
b, err := yaml.Marshal(tc.obj)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tc.want, string(b), "yaml module returned unexpected")
|
||||
assert.Equal(t, tc.want, string(b), "yaml module returned unexpected")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ optional_twostring: null
|
|||
var obj testSerializationStruct
|
||||
err := yaml.Unmarshal([]byte(tc.data), &obj)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, tc.want, obj, "yaml module returned unexpected")
|
||||
assert.Equal(t, tc.want, obj, "yaml module returned unexpected")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ func TestParsePackage(t *testing.T) {
|
|||
assert.Equal(t, []string{author}, cp.Metadata.Authors)
|
||||
assert.Len(t, cp.Metadata.Dependencies, 2)
|
||||
assert.Equal(t, "dep", cp.Metadata.Dependencies[0].Name)
|
||||
assert.EqualValues(t, "v4l2-sys-mit", cp.Metadata.Dependencies[1].Name)
|
||||
assert.EqualValues(t, "v4l2-sys", *cp.Metadata.Dependencies[1].Package)
|
||||
assert.Equal(t, "v4l2-sys-mit", cp.Metadata.Dependencies[1].Name)
|
||||
assert.Equal(t, "v4l2-sys", *cp.Metadata.Dependencies[1].Package)
|
||||
assert.Equal(t, homepage, cp.Metadata.ProjectURL)
|
||||
assert.Equal(t, license, cp.Metadata.License)
|
||||
content, _ := io.ReadAll(cp.Content)
|
||||
|
|
|
@ -23,19 +23,19 @@ func TestProcessStacktraces(t *testing.T) {
|
|||
t.Run("No flat with no system process", func(t *testing.T) {
|
||||
processes, processCount, _, err := GetManager().ProcessStacktraces(false, true)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 4, processCount)
|
||||
assert.Equal(t, 4, processCount)
|
||||
assert.Len(t, processes, 2)
|
||||
|
||||
assert.EqualValues(t, "Children normal process", processes[0].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[0].Type)
|
||||
assert.Equal(t, "Children normal process", processes[0].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[0].Type)
|
||||
assert.Empty(t, processes[0].ParentPID)
|
||||
assert.Len(t, processes[0].Children, 1)
|
||||
|
||||
assert.EqualValues(t, "Children process", processes[0].Children[0].Description)
|
||||
assert.EqualValues(t, processes[0].PID, processes[0].Children[0].ParentPID)
|
||||
assert.Equal(t, "Children process", processes[0].Children[0].Description)
|
||||
assert.Equal(t, processes[0].PID, processes[0].Children[0].ParentPID)
|
||||
|
||||
assert.EqualValues(t, "Normal process", processes[1].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[1].Type)
|
||||
assert.Equal(t, "Normal process", processes[1].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[1].Type)
|
||||
assert.Empty(t, processes[1].ParentPID)
|
||||
assert.Empty(t, processes[1].Children)
|
||||
})
|
||||
|
@ -43,21 +43,21 @@ func TestProcessStacktraces(t *testing.T) {
|
|||
t.Run("Flat with no system process", func(t *testing.T) {
|
||||
processes, processCount, _, err := GetManager().ProcessStacktraces(true, true)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 4, processCount)
|
||||
assert.Equal(t, 4, processCount)
|
||||
assert.Len(t, processes, 3)
|
||||
|
||||
assert.EqualValues(t, "Children process", processes[0].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[0].Type)
|
||||
assert.EqualValues(t, processes[1].PID, processes[0].ParentPID)
|
||||
assert.Equal(t, "Children process", processes[0].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[0].Type)
|
||||
assert.Equal(t, processes[1].PID, processes[0].ParentPID)
|
||||
assert.Empty(t, processes[0].Children)
|
||||
|
||||
assert.EqualValues(t, "Children normal process", processes[1].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[1].Type)
|
||||
assert.Equal(t, "Children normal process", processes[1].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[1].Type)
|
||||
assert.Empty(t, processes[1].ParentPID)
|
||||
assert.Empty(t, processes[1].Children)
|
||||
|
||||
assert.EqualValues(t, "Normal process", processes[2].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[2].Type)
|
||||
assert.Equal(t, "Normal process", processes[2].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[2].Type)
|
||||
assert.Empty(t, processes[2].ParentPID)
|
||||
assert.Empty(t, processes[2].Children)
|
||||
})
|
||||
|
@ -65,27 +65,27 @@ func TestProcessStacktraces(t *testing.T) {
|
|||
t.Run("System process", func(t *testing.T) {
|
||||
processes, processCount, _, err := GetManager().ProcessStacktraces(false, false)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 4, processCount)
|
||||
assert.Equal(t, 4, processCount)
|
||||
assert.Len(t, processes, 4)
|
||||
|
||||
assert.EqualValues(t, "System process", processes[0].Description)
|
||||
assert.EqualValues(t, SystemProcessType, processes[0].Type)
|
||||
assert.Equal(t, "System process", processes[0].Description)
|
||||
assert.Equal(t, SystemProcessType, processes[0].Type)
|
||||
assert.Empty(t, processes[0].ParentPID)
|
||||
assert.Empty(t, processes[0].Children)
|
||||
|
||||
assert.EqualValues(t, "Children normal process", processes[1].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[1].Type)
|
||||
assert.Equal(t, "Children normal process", processes[1].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[1].Type)
|
||||
assert.Empty(t, processes[1].ParentPID)
|
||||
assert.Len(t, processes[1].Children, 1)
|
||||
|
||||
assert.EqualValues(t, "Normal process", processes[2].Description)
|
||||
assert.EqualValues(t, NormalProcessType, processes[2].Type)
|
||||
assert.Equal(t, "Normal process", processes[2].Description)
|
||||
assert.Equal(t, NormalProcessType, processes[2].Type)
|
||||
assert.Empty(t, processes[2].ParentPID)
|
||||
assert.Empty(t, processes[2].Children)
|
||||
|
||||
// This is the "main" pid, testing code always runs in a goroutine.
|
||||
assert.EqualValues(t, "(unassociated)", processes[3].Description)
|
||||
assert.EqualValues(t, NoneProcessType, processes[3].Type)
|
||||
assert.Equal(t, "(unassociated)", processes[3].Description)
|
||||
assert.Equal(t, NoneProcessType, processes[3].Type)
|
||||
assert.Empty(t, processes[3].ParentPID)
|
||||
assert.Empty(t, processes[3].Children)
|
||||
})
|
||||
|
|
|
@ -22,7 +22,7 @@ func testQueueBasic(t *testing.T, newFn func(cfg *BaseConfig) (baseQueue, error)
|
|||
_ = q.RemoveAll(ctx)
|
||||
cnt, err := q.Len(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 0, cnt)
|
||||
assert.Equal(t, 0, cnt)
|
||||
|
||||
// push the first item
|
||||
err = q.PushItem(ctx, []byte("foo"))
|
||||
|
@ -30,7 +30,7 @@ func testQueueBasic(t *testing.T, newFn func(cfg *BaseConfig) (baseQueue, error)
|
|||
|
||||
cnt, err = q.Len(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 1, cnt)
|
||||
assert.Equal(t, 1, cnt)
|
||||
|
||||
// push a duplicate item
|
||||
err = q.PushItem(ctx, []byte("foo"))
|
||||
|
@ -46,10 +46,10 @@ func testQueueBasic(t *testing.T, newFn func(cfg *BaseConfig) (baseQueue, error)
|
|||
has, err := q.HasItem(ctx, []byte("foo"))
|
||||
require.NoError(t, err)
|
||||
if !isUnique {
|
||||
assert.EqualValues(t, 2, cnt)
|
||||
assert.Equal(t, 2, cnt)
|
||||
assert.False(t, has) // non-unique queues don't check for duplicates
|
||||
} else {
|
||||
assert.EqualValues(t, 1, cnt)
|
||||
assert.Equal(t, 1, cnt)
|
||||
assert.True(t, has)
|
||||
}
|
||||
|
||||
|
@ -60,18 +60,18 @@ func testQueueBasic(t *testing.T, newFn func(cfg *BaseConfig) (baseQueue, error)
|
|||
// pop the first item (and the duplicate if non-unique)
|
||||
it, err := q.PopItem(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "foo", string(it))
|
||||
assert.Equal(t, "foo", string(it))
|
||||
|
||||
if !isUnique {
|
||||
it, err = q.PopItem(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "foo", string(it))
|
||||
assert.Equal(t, "foo", string(it))
|
||||
}
|
||||
|
||||
// pop another item
|
||||
it, err = q.PopItem(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "bar", string(it))
|
||||
assert.Equal(t, "bar", string(it))
|
||||
|
||||
// pop an empty queue (timeout, cancel)
|
||||
ctxTimed, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
|
||||
|
@ -108,13 +108,13 @@ func testQueueBasic(t *testing.T, newFn func(cfg *BaseConfig) (baseQueue, error)
|
|||
// remove all
|
||||
cnt, err = q.Len(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, cfg.Length, cnt)
|
||||
assert.Equal(t, cfg.Length, cnt)
|
||||
|
||||
_ = q.RemoveAll(ctx)
|
||||
|
||||
cnt, err = q.Len(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 0, cnt)
|
||||
assert.Equal(t, 0, cnt)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ func TestBaseDummy(t *testing.T) {
|
|||
|
||||
cnt, err := q.Len(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, 0, cnt)
|
||||
assert.Equal(t, 0, cnt)
|
||||
|
||||
has, err := q.HasItem(ctx, []byte("foo"))
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -48,7 +48,7 @@ CONN_STR = redis://
|
|||
assert.Equal(t, filepath.Join(setting.AppDataPath, "queues/common"), q.baseConfig.DataFullDir)
|
||||
assert.Equal(t, 100000, q.baseConfig.Length)
|
||||
assert.Equal(t, 20, q.batchLength)
|
||||
assert.Equal(t, "", q.baseConfig.ConnStr)
|
||||
assert.Empty(t, q.baseConfig.ConnStr)
|
||||
assert.Equal(t, "default_queue", q.baseConfig.QueueFullName)
|
||||
assert.Equal(t, "default_queue_unique", q.baseConfig.SetFullName)
|
||||
assert.NotZero(t, q.GetWorkerMaxNumber())
|
||||
|
@ -102,7 +102,7 @@ MAX_WORKERS = 123
|
|||
assert.Equal(t, filepath.Join(setting.AppDataPath, "queues/dir2"), q2.baseConfig.DataFullDir)
|
||||
assert.Equal(t, 102, q2.baseConfig.Length)
|
||||
assert.Equal(t, 22, q2.batchLength)
|
||||
assert.Equal(t, "", q2.baseConfig.ConnStr)
|
||||
assert.Empty(t, q2.baseConfig.ConnStr)
|
||||
assert.Equal(t, "sub_q2", q2.baseConfig.QueueFullName)
|
||||
assert.Equal(t, "sub_q2_u2", q2.baseConfig.SetFullName)
|
||||
assert.Equal(t, 123, q2.GetWorkerMaxNumber())
|
||||
|
|
|
@ -64,9 +64,9 @@ func TestWorkerPoolQueueUnhandled(t *testing.T) {
|
|||
ok := true
|
||||
for i := 0; i < queueSetting.Length; i++ {
|
||||
if i%2 == 0 {
|
||||
ok = ok && assert.EqualValues(t, 2, m[i], "test %s: item %d", t.Name(), i)
|
||||
ok = ok && assert.Equal(t, 2, m[i], "test %s: item %d", t.Name(), i)
|
||||
} else {
|
||||
ok = ok && assert.EqualValues(t, 1, m[i], "test %s: item %d", t.Name(), i)
|
||||
ok = ok && assert.Equal(t, 1, m[i], "test %s: item %d", t.Name(), i)
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
|
@ -174,7 +174,7 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett
|
|||
|
||||
assert.NotEmpty(t, tasksQ1)
|
||||
assert.NotEmpty(t, tasksQ2)
|
||||
assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2))
|
||||
assert.Equal(t, testCount, len(tasksQ1)+len(tasksQ2))
|
||||
}
|
||||
|
||||
func TestWorkerPoolQueueActiveWorkers(t *testing.T) {
|
||||
|
@ -192,13 +192,13 @@ func TestWorkerPoolQueueActiveWorkers(t *testing.T) {
|
|||
}
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
assert.EqualValues(t, 1, q.GetWorkerNumber())
|
||||
assert.EqualValues(t, 1, q.GetWorkerActiveNumber())
|
||||
assert.Equal(t, 1, q.GetWorkerNumber())
|
||||
assert.Equal(t, 1, q.GetWorkerActiveNumber())
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
assert.EqualValues(t, 1, q.GetWorkerNumber())
|
||||
assert.EqualValues(t, 0, q.GetWorkerActiveNumber())
|
||||
assert.Equal(t, 1, q.GetWorkerNumber())
|
||||
assert.Equal(t, 0, q.GetWorkerActiveNumber())
|
||||
time.Sleep(workerIdleDuration)
|
||||
assert.EqualValues(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
|
||||
assert.Equal(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
|
||||
stop()
|
||||
|
||||
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 3, Length: 100}, handler, false)
|
||||
|
@ -208,13 +208,13 @@ func TestWorkerPoolQueueActiveWorkers(t *testing.T) {
|
|||
}
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
assert.EqualValues(t, 3, q.GetWorkerNumber())
|
||||
assert.EqualValues(t, 3, q.GetWorkerActiveNumber())
|
||||
assert.Equal(t, 3, q.GetWorkerNumber())
|
||||
assert.Equal(t, 3, q.GetWorkerActiveNumber())
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
assert.EqualValues(t, 3, q.GetWorkerNumber())
|
||||
assert.EqualValues(t, 0, q.GetWorkerActiveNumber())
|
||||
assert.Equal(t, 3, q.GetWorkerNumber())
|
||||
assert.Equal(t, 0, q.GetWorkerActiveNumber())
|
||||
time.Sleep(workerIdleDuration)
|
||||
assert.EqualValues(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
|
||||
assert.Equal(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
|
||||
stop()
|
||||
}
|
||||
|
||||
|
@ -241,13 +241,13 @@ func TestWorkerPoolQueueShutdown(t *testing.T) {
|
|||
}
|
||||
<-handlerCalled
|
||||
time.Sleep(200 * time.Millisecond) // wait for a while to make sure all workers are active
|
||||
assert.EqualValues(t, 4, q.GetWorkerActiveNumber())
|
||||
assert.Equal(t, 4, q.GetWorkerActiveNumber())
|
||||
stop() // stop triggers shutdown
|
||||
assert.EqualValues(t, 0, q.GetWorkerActiveNumber())
|
||||
assert.Equal(t, 0, q.GetWorkerActiveNumber())
|
||||
|
||||
// no item was ever handled, so we still get all of them again
|
||||
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", qs, handler, false)
|
||||
assert.EqualValues(t, 20, q.GetQueueItemNumber())
|
||||
assert.Equal(t, 20, q.GetQueueItemNumber())
|
||||
}
|
||||
|
||||
func TestWorkerPoolQueueWorkerIdleReset(t *testing.T) {
|
||||
|
|
|
@ -464,11 +464,12 @@ func findAllIssueReferencesBytes(content []byte, links []string) []*rawReference
|
|||
continue
|
||||
}
|
||||
var sep string
|
||||
if parts[3] == "issues" {
|
||||
switch parts[3] {
|
||||
case "issues":
|
||||
sep = "#"
|
||||
} else if parts[3] == "pulls" {
|
||||
case "pulls":
|
||||
sep = "!"
|
||||
} else {
|
||||
default:
|
||||
continue
|
||||
}
|
||||
// Note: closing/reopening keywords not supported with URLs
|
||||
|
|
|
@ -46,7 +46,7 @@ owner/repo!123456789
|
|||
contentBytes := []byte(test)
|
||||
convertFullHTMLReferencesToShortRefs(re, &contentBytes)
|
||||
result := string(contentBytes)
|
||||
assert.EqualValues(t, expect, result)
|
||||
assert.Equal(t, expect, result)
|
||||
}
|
||||
|
||||
func TestFindAllIssueReferences(t *testing.T) {
|
||||
|
@ -284,9 +284,9 @@ func testFixtures(t *testing.T, fixtures []testFixture, context string) {
|
|||
}
|
||||
expref := rawToIssueReferenceList(expraw)
|
||||
refs := FindAllIssueReferencesMarkdown(fixture.input)
|
||||
assert.EqualValues(t, expref, refs, "[%s] Failed to parse: {%s}", context, fixture.input)
|
||||
assert.Equal(t, expref, refs, "[%s] Failed to parse: {%s}", context, fixture.input)
|
||||
rawrefs := findAllIssueReferencesMarkdown(fixture.input)
|
||||
assert.EqualValues(t, expraw, rawrefs, "[%s] Failed to parse: {%s}", context, fixture.input)
|
||||
assert.Equal(t, expraw, rawrefs, "[%s] Failed to parse: {%s}", context, fixture.input)
|
||||
}
|
||||
|
||||
// Restore for other tests that may rely on the original value
|
||||
|
@ -295,7 +295,7 @@ func testFixtures(t *testing.T, fixtures []testFixture, context string) {
|
|||
|
||||
func TestFindAllMentions(t *testing.T) {
|
||||
res := FindAllMentionsBytes([]byte("@tasha, @mike; @lucy: @john"))
|
||||
assert.EqualValues(t, []RefSpan{
|
||||
assert.Equal(t, []RefSpan{
|
||||
{Start: 0, End: 6},
|
||||
{Start: 8, End: 13},
|
||||
{Start: 15, End: 20},
|
||||
|
@ -558,7 +558,7 @@ func TestParseCloseKeywords(t *testing.T) {
|
|||
res := pat.FindAllStringSubmatch(test.match, -1)
|
||||
assert.Len(t, res, 1)
|
||||
assert.Len(t, res[0], 2)
|
||||
assert.EqualValues(t, test.expected, res[0][1])
|
||||
assert.Equal(t, test.expected, res[0][1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ func TestRegexpLru(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.True(t, r.MatchString("a"))
|
||||
|
||||
assert.EqualValues(t, 1, lruCache.Len())
|
||||
assert.Equal(t, 1, lruCache.Len())
|
||||
|
||||
_, err = GetCompiled("(")
|
||||
require.Error(t, err)
|
||||
assert.EqualValues(t, 2, lruCache.Len())
|
||||
assert.Equal(t, 2, lruCache.Len())
|
||||
}
|
||||
|
|
|
@ -28,5 +28,5 @@ func TestSyncRepoBranches(t *testing.T) {
|
|||
assert.Equal(t, "sha1", repo.ObjectFormatName)
|
||||
branch, err := git_model.GetBranch(db.DefaultContext, 1, "master")
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "master", branch.Name)
|
||||
assert.Equal(t, "master", branch.Name)
|
||||
}
|
||||
|
|
|
@ -63,9 +63,9 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
|
|||
assert.Equal(t, "user2", payloadCommits[0].Committer.UserName)
|
||||
assert.Equal(t, "User2", payloadCommits[0].Author.Name)
|
||||
assert.Equal(t, "user2", payloadCommits[0].Author.UserName)
|
||||
assert.EqualValues(t, []string{}, payloadCommits[0].Added)
|
||||
assert.EqualValues(t, []string{}, payloadCommits[0].Removed)
|
||||
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[0].Modified)
|
||||
assert.Equal(t, []string{}, payloadCommits[0].Added)
|
||||
assert.Equal(t, []string{}, payloadCommits[0].Removed)
|
||||
assert.Equal(t, []string{"readme.md"}, payloadCommits[0].Modified)
|
||||
|
||||
assert.Equal(t, "27566bd", payloadCommits[1].ID)
|
||||
assert.Equal(t, "good signed commit (with not yet validated email)", payloadCommits[1].Message)
|
||||
|
@ -74,9 +74,9 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
|
|||
assert.Equal(t, "user2", payloadCommits[1].Committer.UserName)
|
||||
assert.Equal(t, "User2", payloadCommits[1].Author.Name)
|
||||
assert.Equal(t, "user2", payloadCommits[1].Author.UserName)
|
||||
assert.EqualValues(t, []string{}, payloadCommits[1].Added)
|
||||
assert.EqualValues(t, []string{}, payloadCommits[1].Removed)
|
||||
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[1].Modified)
|
||||
assert.Equal(t, []string{}, payloadCommits[1].Added)
|
||||
assert.Equal(t, []string{}, payloadCommits[1].Removed)
|
||||
assert.Equal(t, []string{"readme.md"}, payloadCommits[1].Modified)
|
||||
|
||||
assert.Equal(t, "5099b81", payloadCommits[2].ID)
|
||||
assert.Equal(t, "good signed commit", payloadCommits[2].Message)
|
||||
|
@ -85,9 +85,9 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
|
|||
assert.Equal(t, "user2", payloadCommits[2].Committer.UserName)
|
||||
assert.Equal(t, "User2", payloadCommits[2].Author.Name)
|
||||
assert.Equal(t, "user2", payloadCommits[2].Author.UserName)
|
||||
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[2].Added)
|
||||
assert.EqualValues(t, []string{}, payloadCommits[2].Removed)
|
||||
assert.EqualValues(t, []string{}, payloadCommits[2].Modified)
|
||||
assert.Equal(t, []string{"readme.md"}, payloadCommits[2].Added)
|
||||
assert.Equal(t, []string{}, payloadCommits[2].Removed)
|
||||
assert.Equal(t, []string{}, payloadCommits[2].Modified)
|
||||
|
||||
assert.Equal(t, "69554a6", headCommit.ID)
|
||||
assert.Equal(t, "not signed commit", headCommit.Message)
|
||||
|
@ -96,9 +96,9 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
|
|||
assert.Equal(t, "user2", headCommit.Committer.UserName)
|
||||
assert.Equal(t, "User2", headCommit.Author.Name)
|
||||
assert.Equal(t, "user2", headCommit.Author.UserName)
|
||||
assert.EqualValues(t, []string{}, headCommit.Added)
|
||||
assert.EqualValues(t, []string{}, headCommit.Removed)
|
||||
assert.EqualValues(t, []string{"readme.md"}, headCommit.Modified)
|
||||
assert.Equal(t, []string{}, headCommit.Added)
|
||||
assert.Equal(t, []string{}, headCommit.Removed)
|
||||
assert.Equal(t, []string{"readme.md"}, headCommit.Modified)
|
||||
}
|
||||
|
||||
func TestPushCommits_AvatarLink(t *testing.T) {
|
||||
|
|
|
@ -73,7 +73,8 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re
|
|||
}
|
||||
units := make([]repo_model.RepoUnit, 0, len(defaultUnits))
|
||||
for _, tp := range defaultUnits {
|
||||
if tp == unit.TypeIssues {
|
||||
switch tp {
|
||||
case unit.TypeIssues:
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
Type: tp,
|
||||
|
@ -83,7 +84,7 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re
|
|||
EnableDependencies: setting.Service.DefaultEnableDependencies,
|
||||
},
|
||||
})
|
||||
} else if tp == unit.TypePullRequests {
|
||||
case unit.TypePullRequests:
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
Type: tp,
|
||||
|
@ -94,7 +95,7 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re
|
|||
AllowRebaseUpdate: true,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
default:
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
Type: tp,
|
||||
|
|
|
@ -42,5 +42,5 @@ func TestGetDirectorySize(t *testing.T) {
|
|||
|
||||
size, err := getDirectorySize(repo.RepoPath())
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, size, repo.Size)
|
||||
assert.Equal(t, size, repo.Size)
|
||||
}
|
||||
|
|
|
@ -14,17 +14,17 @@ func TestMergeCustomLabels(t *testing.T) {
|
|||
all: []string{"a", "a.yaml", "a.yml"},
|
||||
custom: nil,
|
||||
})
|
||||
assert.EqualValues(t, []string{"a.yaml"}, files, "yaml file should win")
|
||||
assert.Equal(t, []string{"a.yaml"}, files, "yaml file should win")
|
||||
|
||||
files = mergeCustomLabelFiles(optionFileList{
|
||||
all: []string{"a", "a.yaml"},
|
||||
custom: []string{"a"},
|
||||
})
|
||||
assert.EqualValues(t, []string{"a"}, files, "custom file should win")
|
||||
assert.Equal(t, []string{"a"}, files, "custom file should win")
|
||||
|
||||
files = mergeCustomLabelFiles(optionFileList{
|
||||
all: []string{"a", "a.yml", "a.yaml"},
|
||||
custom: []string{"a", "a.yml"},
|
||||
})
|
||||
assert.EqualValues(t, []string{"a.yml"}, files, "custom yml file should win if no yaml")
|
||||
assert.Equal(t, []string{"a.yml"}, files, "custom yml file should win if no yaml")
|
||||
}
|
||||
|
|
|
@ -99,7 +99,8 @@ func getLicensePlaceholder(name string) *licensePlaceholder {
|
|||
|
||||
// Some special placeholders for specific licenses.
|
||||
// It's unsafe to apply them to all licenses.
|
||||
if name == "0BSD" {
|
||||
switch name {
|
||||
case "0BSD":
|
||||
return &licensePlaceholder{
|
||||
Owner: []string{"AUTHOR"},
|
||||
Email: []string{"EMAIL"},
|
||||
|
@ -108,7 +109,7 @@ func getLicensePlaceholder(name string) *licensePlaceholder {
|
|||
}
|
||||
|
||||
// Other special placeholders can be added here.
|
||||
} else if name == "BSD-4-Clause" {
|
||||
case "BSD-4-Clause":
|
||||
ret.Owner = append(ret.Owner, "COPYRIGHT HOLDER")
|
||||
ret.Owner = append(ret.Owner, "the organization")
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func Test_calcSync(t *testing.T) {
|
|||
|
||||
inserts, deletes, updates := calcSync(gitTags, dbReleases)
|
||||
if assert.Len(t, inserts, 1, "inserts") {
|
||||
assert.EqualValues(t, *gitTags[2], *inserts[0], "inserts equal")
|
||||
assert.Equal(t, *gitTags[2], *inserts[0], "inserts equal")
|
||||
}
|
||||
|
||||
if assert.Len(t, deletes, 1, "deletes") {
|
||||
|
@ -71,6 +71,6 @@ func Test_calcSync(t *testing.T) {
|
|||
}
|
||||
|
||||
if assert.Len(t, updates, 1, "updates") {
|
||||
assert.EqualValues(t, *gitTags[1], *updates[0], "updates equal")
|
||||
assert.Equal(t, *gitTags[1], *updates[0], "updates equal")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ func Test_getStorageInheritNameSectionTypeForActions(t *testing.T) {
|
|||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
|
||||
iniStr = `
|
||||
[storage.actions_log]
|
||||
|
@ -34,9 +34,9 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.EqualValues(t, "local", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
|
||||
assert.Equal(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
|
||||
|
||||
iniStr = `
|
||||
[storage.actions_log]
|
||||
|
@ -50,9 +50,9 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.EqualValues(t, "local", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
|
||||
assert.Equal(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
|
||||
|
||||
iniStr = `
|
||||
[storage.actions_artifacts]
|
||||
|
@ -66,9 +66,9 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "local", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
|
||||
assert.Equal(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
|
||||
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
|
||||
iniStr = `
|
||||
[storage.actions_artifacts]
|
||||
|
@ -82,9 +82,9 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "local", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
|
||||
assert.Equal(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
|
||||
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
|
||||
iniStr = ``
|
||||
cfg, err = NewConfigProviderFromData(iniStr)
|
||||
|
@ -92,9 +92,9 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "local", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
|
||||
assert.Equal(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
|
||||
assert.EqualValues(t, "local", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
|
||||
assert.Equal(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
|
||||
}
|
||||
|
||||
func Test_getDefaultActionsURLForActions(t *testing.T) {
|
||||
|
@ -151,7 +151,7 @@ DEFAULT_ACTIONS_URL = https://example.com
|
|||
require.NoError(t, err)
|
||||
require.NoError(t, loadActionsFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, tt.wantURL, Actions.DefaultActionsURL.URL())
|
||||
assert.Equal(t, tt.wantURL, Actions.DefaultActionsURL.URL())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ func Test_loadAdminFrom(t *testing.T) {
|
|||
loadAdminFrom(cfg)
|
||||
|
||||
assert.True(t, Admin.DisableRegularOrgCreation)
|
||||
assert.EqualValues(t, "z", Admin.DefaultEmailNotification)
|
||||
assert.Equal(t, "z", Admin.DefaultEmailNotification)
|
||||
assert.True(t, Admin.SendNotificationEmailOnNewUser)
|
||||
assert.EqualValues(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
|
||||
assert.EqualValues(t, container.SetOf("x", "y"), Admin.ExternalUserDisableFeatures)
|
||||
assert.Equal(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
|
||||
assert.Equal(t, container.SetOf("x", "y"), Admin.ExternalUserDisableFeatures)
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ MINIO_ENDPOINT = my_minio:9000
|
|||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Attachment.Storage.Type)
|
||||
assert.EqualValues(t, "my_minio:9000", Attachment.Storage.MinioConfig.Endpoint)
|
||||
assert.EqualValues(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "my_minio:9000", Attachment.Storage.MinioConfig.Endpoint)
|
||||
assert.Equal(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_getStorageTypeSectionOverridesStorageSection(t *testing.T) {
|
||||
|
@ -48,8 +48,8 @@ MINIO_BUCKET = gitea
|
|||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Attachment.Storage.Type)
|
||||
assert.EqualValues(t, "gitea-minio", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-minio", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_getStorageSpecificOverridesStorage(t *testing.T) {
|
||||
|
@ -70,8 +70,8 @@ STORAGE_TYPE = local
|
|||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Attachment.Storage.Type)
|
||||
assert.EqualValues(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_getStorageGetDefaults(t *testing.T) {
|
||||
|
@ -81,7 +81,7 @@ func Test_getStorageGetDefaults(t *testing.T) {
|
|||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
|
||||
// default storage is local, so bucket is empty
|
||||
assert.EqualValues(t, "", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Empty(t, Attachment.Storage.MinioConfig.Bucket)
|
||||
}
|
||||
|
||||
func Test_getStorageInheritNameSectionType(t *testing.T) {
|
||||
|
@ -116,7 +116,7 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage := Attachment.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
}
|
||||
|
||||
func Test_AttachmentStorage1(t *testing.T) {
|
||||
|
@ -129,6 +129,6 @@ STORAGE_TYPE = minio
|
|||
|
||||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
assert.EqualValues(t, "minio", Attachment.Storage.Type)
|
||||
assert.EqualValues(t, "gitea", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ func TestDecodeEnvSectionKey(t *testing.T) {
|
|||
|
||||
ok, section, key = decodeEnvSectionKey("SEC")
|
||||
assert.False(t, ok)
|
||||
assert.Equal(t, "", section)
|
||||
assert.Equal(t, "", key)
|
||||
assert.Empty(t, section)
|
||||
assert.Empty(t, key)
|
||||
}
|
||||
|
||||
func TestDecodeEnvironmentKey(t *testing.T) {
|
||||
|
@ -40,19 +40,19 @@ func TestDecodeEnvironmentKey(t *testing.T) {
|
|||
|
||||
ok, section, key, file := decodeEnvironmentKey(prefix, suffix, "SEC__KEY")
|
||||
assert.False(t, ok)
|
||||
assert.Equal(t, "", section)
|
||||
assert.Equal(t, "", key)
|
||||
assert.Empty(t, section)
|
||||
assert.Empty(t, key)
|
||||
assert.False(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC")
|
||||
assert.False(t, ok)
|
||||
assert.Equal(t, "", section)
|
||||
assert.Equal(t, "", key)
|
||||
assert.Empty(t, section)
|
||||
assert.Empty(t, key)
|
||||
assert.False(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA____KEY")
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "", section)
|
||||
assert.Empty(t, section)
|
||||
assert.Equal(t, "KEY", key)
|
||||
assert.False(t, file)
|
||||
|
||||
|
@ -72,8 +72,8 @@ func TestDecodeEnvironmentKey(t *testing.T) {
|
|||
// but it could be fixed in the future by adding a new suffix like "__VALUE" (no such key VALUE is used in Gitea either)
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__FILE")
|
||||
assert.False(t, ok)
|
||||
assert.Equal(t, "", section)
|
||||
assert.Equal(t, "", key)
|
||||
assert.Empty(t, section)
|
||||
assert.Empty(t, key)
|
||||
assert.True(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__KEY__FILE")
|
||||
|
|
|
@ -63,17 +63,17 @@ key = 123
|
|||
|
||||
// test default behavior
|
||||
assert.Equal(t, "123", ConfigSectionKeyString(sec, "key"))
|
||||
assert.Equal(t, "", ConfigSectionKeyString(secSub, "key"))
|
||||
assert.Empty(t, ConfigSectionKeyString(secSub, "key"))
|
||||
assert.Equal(t, "def", ConfigSectionKeyString(secSub, "key", "def"))
|
||||
|
||||
assert.Equal(t, "123", ConfigInheritedKeyString(secSub, "key"))
|
||||
|
||||
// Workaround for ini package's BuggyKeyOverwritten behavior
|
||||
assert.Equal(t, "", ConfigSectionKeyString(sec, "empty"))
|
||||
assert.Equal(t, "", ConfigSectionKeyString(secSub, "empty"))
|
||||
assert.Empty(t, ConfigSectionKeyString(sec, "empty"))
|
||||
assert.Empty(t, ConfigSectionKeyString(secSub, "empty"))
|
||||
assert.Equal(t, "def", ConfigInheritedKey(secSub, "empty").MustString("def"))
|
||||
assert.Equal(t, "def", ConfigInheritedKey(secSub, "empty").MustString("xyz"))
|
||||
assert.Equal(t, "", ConfigSectionKeyString(sec, "empty"))
|
||||
assert.Empty(t, ConfigSectionKeyString(sec, "empty"))
|
||||
assert.Equal(t, "def", ConfigSectionKeyString(secSub, "empty"))
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,6 @@ EXTEND = true
|
|||
_, err = getCronSettings(cfg, "test", extended)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, extended.Base)
|
||||
assert.EqualValues(t, "white rabbit", extended.Second)
|
||||
assert.Equal(t, "white rabbit", extended.Second)
|
||||
assert.True(t, extended.Extend)
|
||||
}
|
||||
|
|
|
@ -259,6 +259,6 @@ func testStoragePathMatch(t *testing.T, iniStr string, storageType StorageType,
|
|||
cfg, err := NewConfigProviderFromData(iniStr)
|
||||
require.NoError(t, err, iniStr)
|
||||
require.NoError(t, loadCommonSettingsFrom(cfg), iniStr)
|
||||
assert.EqualValues(t, testSectionToPath(storageType, section), testStorageGetPath(*storage), iniStr)
|
||||
assert.EqualValues(t, storageType, (*storage).Type, iniStr)
|
||||
assert.Equal(t, testSectionToPath(storageType, section), testStorageGetPath(*storage), iniStr)
|
||||
assert.Equal(t, storageType, (*storage).Type, iniStr)
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ a.b = 1
|
|||
`)
|
||||
require.NoError(t, err)
|
||||
loadGitFrom(cfg)
|
||||
assert.EqualValues(t, "1", GitConfig.Options["a.b"])
|
||||
assert.EqualValues(t, "histogram", GitConfig.Options["diff.algorithm"])
|
||||
assert.Equal(t, "1", GitConfig.Options["a.b"])
|
||||
assert.Equal(t, "histogram", GitConfig.Options["diff.algorithm"])
|
||||
|
||||
cfg, err = NewConfigProviderFromData(`
|
||||
[git.config]
|
||||
|
@ -33,7 +33,7 @@ diff.algorithm = other
|
|||
`)
|
||||
require.NoError(t, err)
|
||||
loadGitFrom(cfg)
|
||||
assert.EqualValues(t, "other", GitConfig.Options["diff.algorithm"])
|
||||
assert.Equal(t, "other", GitConfig.Options["diff.algorithm"])
|
||||
}
|
||||
|
||||
func TestGitReflog(t *testing.T) {
|
||||
|
@ -49,8 +49,8 @@ func TestGitReflog(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
loadGitFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, "true", GitConfig.GetOption("core.logAllRefUpdates"))
|
||||
assert.EqualValues(t, "90", GitConfig.GetOption("gc.reflogExpire"))
|
||||
assert.Equal(t, "true", GitConfig.GetOption("core.logAllRefUpdates"))
|
||||
assert.Equal(t, "90", GitConfig.GetOption("gc.reflogExpire"))
|
||||
|
||||
// custom reflog config by legacy options
|
||||
cfg, err = NewConfigProviderFromData(`
|
||||
|
@ -61,6 +61,6 @@ EXPIRATION = 123
|
|||
require.NoError(t, err)
|
||||
loadGitFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, "false", GitConfig.GetOption("core.logAllRefUpdates"))
|
||||
assert.EqualValues(t, "123", GitConfig.GetOption("gc.reflogExpire"))
|
||||
assert.Equal(t, "false", GitConfig.GetOption("core.logAllRefUpdates"))
|
||||
assert.Equal(t, "123", GitConfig.GetOption("gc.reflogExpire"))
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ func Test_loadIncomingEmailFrom(t *testing.T) {
|
|||
|
||||
loadIncomingEmailFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, "jane.doe@example.com", IncomingEmail.Username)
|
||||
assert.EqualValues(t, "y0u'll n3v3r gUess th1S!!1", IncomingEmail.Password)
|
||||
assert.Equal(t, "jane.doe@example.com", IncomingEmail.Username)
|
||||
assert.Equal(t, "y0u'll n3v3r gUess th1S!!1", IncomingEmail.Password)
|
||||
})
|
||||
|
||||
t.Run("Port settings", func(t *testing.T) {
|
||||
|
@ -45,7 +45,7 @@ func Test_loadIncomingEmailFrom(t *testing.T) {
|
|||
|
||||
loadIncomingEmailFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, 143, IncomingEmail.Port)
|
||||
assert.Equal(t, 143, IncomingEmail.Port)
|
||||
})
|
||||
|
||||
t.Run("no port, with tls", func(t *testing.T) {
|
||||
|
@ -56,7 +56,7 @@ func Test_loadIncomingEmailFrom(t *testing.T) {
|
|||
|
||||
loadIncomingEmailFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, 993, IncomingEmail.Port)
|
||||
assert.Equal(t, 993, IncomingEmail.Port)
|
||||
})
|
||||
|
||||
t.Run("port overrides tls", func(t *testing.T) {
|
||||
|
@ -68,7 +68,7 @@ func Test_loadIncomingEmailFrom(t *testing.T) {
|
|||
|
||||
loadIncomingEmailFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, 1993, IncomingEmail.Port)
|
||||
assert.Equal(t, 1993, IncomingEmail.Port)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func Test_getStorageInheritNameSectionTypeForLFS(t *testing.T) {
|
|||
require.NoError(t, loadLFSFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", LFS.Storage.Type)
|
||||
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
|
||||
iniStr = `
|
||||
[server]
|
||||
|
@ -55,7 +55,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadLFSFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", LFS.Storage.Type)
|
||||
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
|
||||
iniStr = `
|
||||
[lfs]
|
||||
|
@ -69,7 +69,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadLFSFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", LFS.Storage.Type)
|
||||
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
|
||||
iniStr = `
|
||||
[lfs]
|
||||
|
@ -84,7 +84,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadLFSFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", LFS.Storage.Type)
|
||||
assert.EqualValues(t, "my_lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "my_lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_LFSStorage1(t *testing.T) {
|
||||
|
@ -97,8 +97,8 @@ STORAGE_TYPE = minio
|
|||
|
||||
require.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, "minio", LFS.Storage.Type)
|
||||
assert.EqualValues(t, "gitea", LFS.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", LFS.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_LFSClientServerConfigs(t *testing.T) {
|
||||
|
@ -113,9 +113,9 @@ BATCH_SIZE = 0
|
|||
assert.NoError(t, err)
|
||||
|
||||
assert.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, 100, LFS.MaxBatchSize)
|
||||
assert.EqualValues(t, 20, LFSClient.BatchSize)
|
||||
assert.EqualValues(t, 8, LFSClient.BatchOperationConcurrency)
|
||||
assert.Equal(t, 100, LFS.MaxBatchSize)
|
||||
assert.Equal(t, 20, LFSClient.BatchSize)
|
||||
assert.Equal(t, 8, LFSClient.BatchOperationConcurrency)
|
||||
|
||||
iniStr = `
|
||||
[lfs_client]
|
||||
|
@ -126,6 +126,6 @@ BATCH_OPERATION_CONCURRENCY = 10
|
|||
assert.NoError(t, err)
|
||||
|
||||
assert.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, 50, LFSClient.BatchSize)
|
||||
assert.EqualValues(t, 10, LFSClient.BatchOperationConcurrency)
|
||||
assert.Equal(t, 50, LFSClient.BatchSize)
|
||||
assert.Equal(t, 10, LFSClient.BatchOperationConcurrency)
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ func Test_loadMailerFrom(t *testing.T) {
|
|||
// Check mailer setting
|
||||
loadMailerFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, kase.SMTPAddr, MailService.SMTPAddr)
|
||||
assert.EqualValues(t, kase.SMTPPort, MailService.SMTPPort)
|
||||
assert.Equal(t, kase.SMTPAddr, MailService.SMTPAddr)
|
||||
assert.Equal(t, kase.SMTPPort, MailService.SMTPPort)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func Test_loadMailerFrom(t *testing.T) {
|
|||
|
||||
loadMailerFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, "jane.doe@example.com", MailService.User)
|
||||
assert.EqualValues(t, "y0u'll n3v3r gUess th1S!!1", MailService.Passwd)
|
||||
assert.Equal(t, "jane.doe@example.com", MailService.User)
|
||||
assert.Equal(t, "y0u'll n3v3r gUess th1S!!1", MailService.Passwd)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ JWT_SECRET = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
|
|||
actual := GetGeneralTokenSigningSecret()
|
||||
expected, _ := generate.DecodeJwtSecret("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")
|
||||
assert.Len(t, actual, 32)
|
||||
assert.EqualValues(t, expected, actual)
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestGetGeneralSigningSecretSave(t *testing.T) {
|
||||
|
|
|
@ -42,7 +42,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadPackagesFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Packages.Storage.Type)
|
||||
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
|
||||
// we can also configure packages storage directly
|
||||
iniStr = `
|
||||
|
@ -54,7 +54,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadPackagesFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Packages.Storage.Type)
|
||||
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
|
||||
// or we can indicate the storage type in the packages section
|
||||
iniStr = `
|
||||
|
@ -69,7 +69,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadPackagesFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Packages.Storage.Type)
|
||||
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
|
||||
// or we can indicate the storage type and minio base path in the packages section
|
||||
iniStr = `
|
||||
|
@ -85,7 +85,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadPackagesFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", Packages.Storage.Type)
|
||||
assert.EqualValues(t, "my_packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "my_packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_PackageStorage1(t *testing.T) {
|
||||
|
@ -110,8 +110,8 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage := Packages.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "packages/", storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "packages/", storage.MinioConfig.BasePath)
|
||||
assert.True(t, storage.MinioConfig.ServeDirect)
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,8 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage := Packages.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "packages/", storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "packages/", storage.MinioConfig.BasePath)
|
||||
assert.True(t, storage.MinioConfig.ServeDirect)
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,8 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage := Packages.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "my_packages/", storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "my_packages/", storage.MinioConfig.BasePath)
|
||||
assert.True(t, storage.MinioConfig.ServeDirect)
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage := Packages.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "my_packages/", storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "my_packages/", storage.MinioConfig.BasePath)
|
||||
assert.True(t, storage.MinioConfig.ServeDirect)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
|
||||
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
|
||||
// we can also configure packages storage directly
|
||||
iniStr = `
|
||||
|
@ -33,7 +33,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
|
||||
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
|
||||
// or we can indicate the storage type in the packages section
|
||||
iniStr = `
|
||||
|
@ -48,7 +48,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
|
||||
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
|
||||
// or we can indicate the storage type and minio base path in the packages section
|
||||
iniStr = `
|
||||
|
@ -64,7 +64,7 @@ STORAGE_TYPE = minio
|
|||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
|
||||
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
|
||||
assert.EqualValues(t, "my_archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "my_archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_RepoArchiveStorage(t *testing.T) {
|
||||
|
@ -86,7 +86,7 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage := RepoArchive.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
|
||||
iniStr = `
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -108,5 +108,5 @@ MINIO_SECRET_ACCESS_KEY = correct_key
|
|||
storage = RepoArchive.Storage
|
||||
|
||||
assert.EqualValues(t, "minio", storage.Type)
|
||||
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
|
||||
}
|
||||
|
|
|
@ -84,5 +84,5 @@ func TestUnixSocketAbstractNamespace(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
loadServerFrom(cfg)
|
||||
|
||||
assert.EqualValues(t, "@forgejo", HTTPAddr)
|
||||
assert.Equal(t, "@forgejo", HTTPAddr)
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ func loadServiceFrom(rootCfg ConfigProvider) {
|
|||
}
|
||||
Service.EmailDomainBlockList = append(Service.EmailDomainBlockList, toAdd...)
|
||||
}
|
||||
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
|
||||
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration && !Service.AllowOnlyExternalRegistration)
|
||||
Service.EnableInternalSignIn = sec.Key("ENABLE_INTERNAL_SIGNIN").MustBool(true)
|
||||
Service.ShowMilestonesDashboardPage = sec.Key("SHOW_MILESTONES_DASHBOARD_PAGE").MustBool(true)
|
||||
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
|
||||
|
|
|
@ -170,8 +170,8 @@ func getStorageTargetSection(rootCfg ConfigProvider, name, typ string, sec Confi
|
|||
targetSec, _ := rootCfg.GetSection(storageSectionName + "." + name)
|
||||
if targetSec != nil {
|
||||
targetType := targetSec.Key("STORAGE_TYPE").String()
|
||||
switch {
|
||||
case targetType == "":
|
||||
switch targetType {
|
||||
case "":
|
||||
if targetSec.Key("PATH").String() == "" { // both storage type and path are empty, use default
|
||||
return getDefaultStorageSection(rootCfg), targetSecIsDefault, nil
|
||||
}
|
||||
|
|
|
@ -27,16 +27,16 @@ MINIO_BUCKET = gitea-storage
|
|||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
assert.EqualValues(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, "gitea-lfs", LFS.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-lfs", LFS.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadAvatarsFrom(cfg))
|
||||
assert.EqualValues(t, "gitea-storage", Avatar.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-storage", Avatar.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_getStorageUseOtherNameAsType(t *testing.T) {
|
||||
|
@ -52,12 +52,12 @@ MINIO_BUCKET = gitea-storage
|
|||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, loadAttachmentFrom(cfg))
|
||||
assert.EqualValues(t, "gitea-storage", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-storage", Attachment.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, "gitea-storage", LFS.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea-storage", LFS.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_getStorageInheritStorageType(t *testing.T) {
|
||||
|
@ -70,32 +70,32 @@ STORAGE_TYPE = minio
|
|||
|
||||
require.NoError(t, loadPackagesFrom(cfg))
|
||||
assert.EqualValues(t, "minio", Packages.Storage.Type)
|
||||
assert.EqualValues(t, "gitea", Packages.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", Packages.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
|
||||
assert.EqualValues(t, "gitea", RepoArchive.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", RepoArchive.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadActionsFrom(cfg))
|
||||
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
|
||||
assert.EqualValues(t, "gitea", Actions.LogStorage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", Actions.LogStorage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
|
||||
|
||||
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
|
||||
assert.EqualValues(t, "gitea", Actions.ArtifactStorage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", Actions.ArtifactStorage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadAvatarsFrom(cfg))
|
||||
assert.EqualValues(t, "minio", Avatar.Storage.Type)
|
||||
assert.EqualValues(t, "gitea", Avatar.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", Avatar.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
|
||||
|
||||
require.NoError(t, loadRepoAvatarFrom(cfg))
|
||||
assert.EqualValues(t, "minio", RepoAvatar.Storage.Type)
|
||||
assert.EqualValues(t, "gitea", RepoAvatar.Storage.MinioConfig.Bucket)
|
||||
assert.EqualValues(t, "repo-avatars/", RepoAvatar.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "gitea", RepoAvatar.Storage.MinioConfig.Bucket)
|
||||
assert.Equal(t, "repo-avatars/", RepoAvatar.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
type testLocalStoragePathCase struct {
|
||||
|
@ -114,7 +114,7 @@ func testLocalStoragePath(t *testing.T, appDataPath, iniStr string, cases []test
|
|||
|
||||
assert.EqualValues(t, "local", storage.Type)
|
||||
assert.True(t, filepath.IsAbs(storage.Path))
|
||||
assert.EqualValues(t, filepath.Clean(c.expectedPath), filepath.Clean(storage.Path))
|
||||
assert.Equal(t, filepath.Clean(c.expectedPath), filepath.Clean(storage.Path))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,8 +352,8 @@ MINIO_SECRET_ACCESS_KEY = my_secret_key
|
|||
|
||||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
cp := RepoArchive.Storage.ToShadowCopy()
|
||||
assert.EqualValues(t, "******", cp.MinioConfig.AccessKeyID)
|
||||
assert.EqualValues(t, "******", cp.MinioConfig.SecretAccessKey)
|
||||
assert.Equal(t, "******", cp.MinioConfig.AccessKeyID)
|
||||
assert.Equal(t, "******", cp.MinioConfig.SecretAccessKey)
|
||||
}
|
||||
|
||||
func Test_getStorageConfiguration24(t *testing.T) {
|
||||
|
@ -408,10 +408,10 @@ MINIO_USE_SSL = true
|
|||
`)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
assert.EqualValues(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
|
||||
assert.EqualValues(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.Equal(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
|
||||
assert.Equal(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.True(t, RepoArchive.Storage.MinioConfig.UseSSL)
|
||||
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
||||
func Test_getStorageConfiguration28(t *testing.T) {
|
||||
|
@ -425,10 +425,10 @@ MINIO_BASE_PATH = /prefix
|
|||
`)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, loadRepoArchiveFrom(cfg))
|
||||
assert.EqualValues(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
|
||||
assert.EqualValues(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.Equal(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
|
||||
assert.Equal(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.True(t, RepoArchive.Storage.MinioConfig.UseSSL)
|
||||
assert.EqualValues(t, "/prefix/repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "/prefix/repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
|
||||
|
||||
cfg, err = NewConfigProviderFromData(`
|
||||
[storage]
|
||||
|
@ -443,10 +443,10 @@ MINIO_BASE_PATH = /lfs
|
|||
`)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
|
||||
assert.EqualValues(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.Equal(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
|
||||
assert.Equal(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.True(t, LFS.Storage.MinioConfig.UseSSL)
|
||||
assert.EqualValues(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
|
||||
|
||||
cfg, err = NewConfigProviderFromData(`
|
||||
[storage]
|
||||
|
@ -461,8 +461,8 @@ MINIO_BASE_PATH = /lfs
|
|||
`)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, loadLFSFrom(cfg))
|
||||
assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
|
||||
assert.EqualValues(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.Equal(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
|
||||
assert.Equal(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
|
||||
assert.True(t, LFS.Storage.MinioConfig.UseSSL)
|
||||
assert.EqualValues(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
|
||||
assert.Equal(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestBuildLocalPath(t *testing.T) {
|
|||
t.Run(k.path, func(t *testing.T) {
|
||||
l := LocalStorage{dir: k.localDir}
|
||||
|
||||
assert.EqualValues(t, k.expected, l.buildLocalPath(k.path))
|
||||
assert.Equal(t, k.expected, l.buildLocalPath(k.path))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ type minioFileInfo struct {
|
|||
}
|
||||
|
||||
func (m minioFileInfo) Name() string {
|
||||
return path.Base(m.ObjectInfo.Key)
|
||||
return path.Base(m.Key)
|
||||
}
|
||||
|
||||
func (m minioFileInfo) Size() int64 {
|
||||
|
@ -243,7 +243,7 @@ func (m minioFileInfo) ModTime() time.Time {
|
|||
}
|
||||
|
||||
func (m minioFileInfo) IsDir() bool {
|
||||
return strings.HasSuffix(m.ObjectInfo.Key, "/")
|
||||
return strings.HasSuffix(m.Key, "/")
|
||||
}
|
||||
|
||||
func (m minioFileInfo) Mode() os.FileMode {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue