diff --git a/internal/forms/multipart_test.go b/internal/forms/multipart_test.go index 632c515..3dbc546 100644 --- a/internal/forms/multipart_test.go +++ b/internal/forms/multipart_test.go @@ -24,12 +24,16 @@ func makeExportRequest(ej *xport.ExportJob, url string) *http.Request { perr(body.WriteField("systemID", strconv.Itoa(int(ej.SystemID)))) + perr(body.WriteField("talkgroups", "3,4")) + w, err := body.CreateFormFile("template", ej.TemplateFileName) perr(err) _, err = w.Write(ej.Template) perr(err) + body.Close() + r, err := http.NewRequest(http.MethodPost, url, &buf) perr(err) diff --git a/internal/forms/unmarshal_test.go b/internal/forms/unmarshal_test.go index 25ec5d2..bdc32e7 100644 --- a/internal/forms/unmarshal_test.go +++ b/internal/forms/unmarshal_test.go @@ -14,6 +14,8 @@ import ( "dynatron.me/x/stillbox/pkg/alerting" "dynatron.me/x/stillbox/pkg/config" + "dynatron.me/x/stillbox/pkg/talkgroups" + "dynatron.me/x/stillbox/pkg/talkgroups/filter" "dynatron.me/x/stillbox/pkg/talkgroups/tgstore" "dynatron.me/x/stillbox/pkg/talkgroups/xport" @@ -131,6 +133,13 @@ var ( SystemID: 197, Template: []byte("this is a template\n\r\nthingy"), TemplateFileName: "template.xml", + + TalkgroupFilter: filter.TalkgroupFilter{ + Talkgroups: []talkgroups.ID{ + talkgroups.TG(197, 3), + talkgroups.TG(197, 4), + }, + }, } ) @@ -253,6 +262,13 @@ func TestUnmarshal(t *testing.T) { expect: &ExpJob1, opts: []forms.Option{forms.WithAcceptBlank(), forms.WithOmitEmpty()}, }, + { + name: "multipart byte field", + r: makeExportRequest(&ExpJob1, "http://somewhere/export"), + dest: &xport.ExportJob{}, + expect: &ExpJob1, + opts: []forms.Option{forms.WithAcceptBlank(), forms.WithOmitEmpty()}, + }, } for _, tc := range tests { diff --git a/pkg/talkgroups/filter/filter.go b/pkg/talkgroups/filter/filter.go index 3072261..11c38c7 100644 --- a/pkg/talkgroups/filter/filter.go +++ b/pkg/talkgroups/filter/filter.go @@ -11,11 +11,11 @@ import ( ) type TalkgroupFilter struct { - Talkgroups []tgsp.ID `json:"talkgroups,omitempty"` - TalkgroupsNot []tgsp.ID `json:"talkgroupsNot,omitempty"` - TalkgroupTagsAll []string `json:"talkgroupTagsAll,omitempty"` - TalkgroupTagsAny []string `json:"talkgroupTagsAny,omitempty"` - TalkgroupTagsNot []string `json:"talkgroupTagsNot,omitempty"` + Talkgroups []tgsp.ID `json:"talkgroups,omitempty" form:"talkgroups"` + TalkgroupsNot []tgsp.ID `json:"talkgroupsNot,omitempty" form:"talkgroupsNot"` + TalkgroupTagsAll []string `json:"talkgroupTagsAll,omitempty" form:"talkgroupTagsAll"` + TalkgroupTagsAny []string `json:"talkgroupTagsAny,omitempty" form:"talkgroupTagsAny"` + TalkgroupTagsNot []string `json:"talkgroupTagsNot,omitempty" form:"talkgroupTagsNot"` talkgroups map[tgsp.ID]bool `json:"-"` }