Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/utils/upload/categories_test.go

39 lignes
991 B
Go

package upload
import (
"testing"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/models"
"github.com/stretchr/testify/assert"
)
func TestCategory(t *testing.T) {
assert := assert.New(t)
dummyTorrent := &models.Torrent{Category: 1, SubCategory: 1}
tests := []struct {
torrent *models.Torrent
platform int
sukebei bool
expected string
}{
{dummyTorrent, anidex, false, ""},
{dummyTorrent, ttosho, false, "5"},
{dummyTorrent, ttosho, true, "12"},
{dummyTorrent, nyaasi, false, "6_1"},
{dummyTorrent, nyaasi, true, "1_1"},
{dummyTorrent, 20, true, ""},
{&models.Torrent{Category: 33, SubCategory: 33}, nyaasi, true, ""},
}
for _, test := range tests {
if test.sukebei {
// workaround to make the function believe we are in sukebei
config.Get().Models.TorrentsTableName = "sukebei_torrents"
} else {
config.Get().Models.TorrentsTableName = "torrents"
}
assert.Equal(test.expected, Category(test.platform, test.torrent))
}
}