Skip to content

Commit 1404777

Browse files
committed
Add edge case tests
1 parent 3915c40 commit 1404777

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

internal/mode/static/telemetry/collector_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,4 +918,44 @@ var _ = Describe("Collector", Ordered, func() {
918918
})
919919
})
920920
})
921+
922+
Describe("snippetsFilters collector", func() {
923+
When("collecting snippetsFilters data", func() {
924+
It("collects correct data for nil snippetsFilters", func(ctx SpecContext) {
925+
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{
926+
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
927+
{Namespace: "test", Name: "sf-1"}: nil,
928+
},
929+
})
930+
931+
expData.SnippetsFilterCount = 1
932+
933+
data, err := dataCollector.Collect(ctx)
934+
935+
Expect(err).ToNot(HaveOccurred())
936+
Expect(data).To(Equal(expData))
937+
})
938+
939+
It("collects correct data when snippetsFilters context is not supported", func(ctx SpecContext) {
940+
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{
941+
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
942+
{Namespace: "test", Name: "sf-1"}: {
943+
Snippets: map[ngfAPI.NginxContext]string{
944+
"unsupportedContext": "worker_priority 0;",
945+
},
946+
},
947+
},
948+
})
949+
950+
expData.SnippetsFilterCount = 1
951+
expData.SnippetsFiltersDirectives = []string{"worker_priority-unknown"}
952+
expData.SnippetsFiltersDirectivesCount = []int64{1}
953+
954+
data, err := dataCollector.Collect(ctx)
955+
956+
Expect(err).ToNot(HaveOccurred())
957+
Expect(data).To(Equal(expData))
958+
})
959+
})
960+
})
921961
})

0 commit comments

Comments
 (0)