35 lines
1017 B
Go
35 lines
1017 B
Go
package service
|
|
|
|
import "testing"
|
|
|
|
func TestParseTemplateSlots(t *testing.T) {
|
|
raw := map[string]any{
|
|
"slots": map[string]any{
|
|
"inputs": []any{
|
|
map[string]any{"name": "video_input_main", "type": "video_source", "required": true},
|
|
},
|
|
"services": []any{
|
|
map[string]any{"name": "object_storage_main", "type": "object_storage", "required": true},
|
|
},
|
|
"outputs": []any{
|
|
map[string]any{"name": "stream_output_main", "type": "stream_publish", "required": true},
|
|
},
|
|
},
|
|
}
|
|
|
|
slots, err := parseTemplateSlots(raw)
|
|
if err != nil {
|
|
t.Fatalf("parseTemplateSlots: %v", err)
|
|
}
|
|
if len(slots.Inputs) != 1 || slots.Inputs[0].Name != "video_input_main" {
|
|
t.Fatalf("unexpected input slots: %#v", slots.Inputs)
|
|
}
|
|
if len(slots.Services) != 1 || slots.Services[0].Type != "object_storage" {
|
|
t.Fatalf("unexpected service slots: %#v", slots.Services)
|
|
}
|
|
if len(slots.Outputs) != 1 || slots.Outputs[0].Name != "stream_output_main" {
|
|
t.Fatalf("unexpected output slots: %#v", slots.Outputs)
|
|
}
|
|
}
|
|
|