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/models/tag_test.go
kilo 8ec3c2a743
Add possibility of reporting without JS, add report reason for NSFW content, Add possibility of getting a torrent by Hash in refine (#1709)
* Add possibility of reporting without JS

* Add report message input and new report reason to /report/:id page

* add new report reason here too

* Update en-us.all.json

* Update CHANGELOG.md

* only show if not sukebei

* ditto

* fix label for value

* ditto

* fix overly big report message column

* Update main.css

* Update search.jet.html

* Add possibility of getting a torrent by Hash in refine

* Update search.go

* Update search.go

* fix template_test

* ditto

* fix Sprintf wrongly using a Token

* rollback that

* Update callback.go

* remove line that creates error

* fix travis
2017-11-04 06:42:36 +01:00

25 lignes
1 Kio
Go

package models
import (
"reflect"
"testing"
"github.com/NyaaPantsu/nyaa/config"
"github.com/stretchr/testify/assert"
)
func TestTagsType(t *testing.T) {
assert := assert.New(t)
torrent := &Torrent{}
for _, tagConf := range config.Get().Torrents.Tags.Types {
assert.NotEmpty(tagConf.Name, "A name must be provided for a tag type")
assert.NotEmpty(tagConf.Field, "You need to provide a field from the torrent Struct for '%s' tag type in config", tagConf.Name)
if tagConf.Defaults != nil && len(tagConf.Defaults) == 0 {
t.Logf("For '%s', you provided a defaults attributes but it is empty. You should remove the attribute or fill it", tagConf.Name)
}
field := reflect.ValueOf(torrent).Elem().FieldByName(tagConf.Field)
assert.True(field.IsValid(), "The field '%s' provided for '%s' doesn't exist", tagConf.Field, tagConf.Name)
// assert.Equal(reflect.String, field.Type().Kind(), "Only string tag types are supported, if you want to make an array do a string splitted by commas for '%s'", tagConf.Name)
}
}