code.gitea.io/gitea@v1.21.7/services/convert/utils_test.go (about) 1 // Copyright 2021 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package convert 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestToCorrectPageSize(t *testing.T) { 13 assert.EqualValues(t, 30, ToCorrectPageSize(0)) 14 assert.EqualValues(t, 30, ToCorrectPageSize(-10)) 15 assert.EqualValues(t, 20, ToCorrectPageSize(20)) 16 assert.EqualValues(t, 50, ToCorrectPageSize(100)) 17 } 18 19 func TestToGitServiceType(t *testing.T) { 20 tc := []struct { 21 typ string 22 enum int 23 }{{ 24 typ: "github", enum: 2, 25 }, { 26 typ: "gitea", enum: 3, 27 }, { 28 typ: "gitlab", enum: 4, 29 }, { 30 typ: "gogs", enum: 5, 31 }, { 32 typ: "trash", enum: 1, 33 }} 34 for _, test := range tc { 35 assert.EqualValues(t, test.enum, ToGitServiceType(test.typ)) 36 } 37 }