(tested) refactor code

* add sentinel master parameter into driver config
* replace yaml double deserialization with `mapstructure` in initializers
* replace struct initializers with registered functions
* add torrent approval MD and a sanitize rest MDs
This commit is contained in:
Lawrence, Rendall
2022-04-16 00:21:47 +03:00
parent 397e106396
commit 8cd8343757
32 changed files with 473 additions and 385 deletions

View File

@@ -6,9 +6,9 @@ import (
"testing"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"github.com/sot-tech/mochi/bittorrent"
"github.com/sot-tech/mochi/pkg/conf"
"github.com/sot-tech/mochi/storage/memory"
)
@@ -71,10 +71,8 @@ func TestHandleAnnounce(t *testing.T) {
require.Nil(t, err)
for _, tt := range cases {
t.Run(fmt.Sprintf("testing hash %s", tt.ih), func(t *testing.T) {
d := driver{}
cfg, err := yaml.Marshal(tt.cfg)
require.Nil(t, err)
h, err := d.NewHook(cfg, storage)
cfg := conf.MapConfig{"initial_source": tt.cfg.Source, "configuration": tt.cfg.Configuration}
h, err := build(cfg, storage)
require.Nil(t, err)
ctx := context.Background()