From 83146efec51146c4e6fafd530ebd9d29584e2288 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 22 Feb 2023 14:01:47 +0100 Subject: pkg/subsystem: query child subsystems Let the Service also serve the child subsystem query requests. --- pkg/subsystem/service_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pkg/subsystem/service_test.go (limited to 'pkg/subsystem/service_test.go') diff --git a/pkg/subsystem/service_test.go b/pkg/subsystem/service_test.go new file mode 100644 index 000000000..2a95b9558 --- /dev/null +++ b/pkg/subsystem/service_test.go @@ -0,0 +1,19 @@ +// Copyright 2023 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package subsystem + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestServiceChildren(t *testing.T) { + unrelated := &Subsystem{Name: "unrelated"} + parent := &Subsystem{Name: "parent"} + childA := &Subsystem{Name: "childA", Parents: []*Subsystem{parent}} + childB := &Subsystem{Name: "childB", Parents: []*Subsystem{parent}} + service := MustMakeService([]*Subsystem{unrelated, parent, childA, childB}) + assert.ElementsMatch(t, service.Children(parent), []*Subsystem{childA, childB}) +} -- cgit mrf-deployment