forgejo/services/convert/utils_test.go
cassiozareck 55c70a0e18
[FEAT] add Forgero Git Service
Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
(cherry picked from commit a878adfe62)

Adding description and Forgejo SVG

(cherry picked from commit 13738c0380)

Undo reordering and tmpl redirection

(cherry picked from commit 9ae51c46f4)
(cherry picked from commit 70fffdc61d)
(cherry picked from commit c0ebfa9da3)
(cherry picked from commit 9922c92787)
(cherry picked from commit 00c0effbc7)
(cherry picked from commit e4c9525b13)
(cherry picked from commit 09d7b83211)
(cherry picked from commit bbcd5975c9)
2023-10-09 19:11:03 +02:00

40 lines
789 B
Go

// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package convert
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToCorrectPageSize(t *testing.T) {
assert.EqualValues(t, 30, ToCorrectPageSize(0))
assert.EqualValues(t, 30, ToCorrectPageSize(-10))
assert.EqualValues(t, 20, ToCorrectPageSize(20))
assert.EqualValues(t, 50, ToCorrectPageSize(100))
}
func TestToGitServiceType(t *testing.T) {
tc := []struct {
typ string
enum int
}{{
typ: "github", enum: 2,
}, {
typ: "gitea", enum: 3,
}, {
typ: "gitlab", enum: 4,
}, {
typ: "gogs", enum: 5,
}, {
typ: "forgejo", enum: 9,
}, {
typ: "trash", enum: 1,
}}
for _, test := range tc {
assert.EqualValues(t, test.enum, ToGitServiceType(test.typ))
}
}