Skip to content

Commit

Permalink
Add edge case tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjee19 committed Oct 14, 2024
1 parent 3915c40 commit 1404777
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions internal/mode/static/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,4 +918,44 @@ var _ = Describe("Collector", Ordered, func() {
})
})
})

Describe("snippetsFilters collector", func() {
When("collecting snippetsFilters data", func() {
It("collects correct data for nil snippetsFilters", func(ctx SpecContext) {
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
{Namespace: "test", Name: "sf-1"}: nil,
},
})

expData.SnippetsFilterCount = 1

data, err := dataCollector.Collect(ctx)

Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal(expData))
})

It("collects correct data when snippetsFilters context is not supported", func(ctx SpecContext) {
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{
SnippetsFilters: map[types.NamespacedName]*graph.SnippetsFilter{
{Namespace: "test", Name: "sf-1"}: {
Snippets: map[ngfAPI.NginxContext]string{
"unsupportedContext": "worker_priority 0;",
},
},
},
})

expData.SnippetsFilterCount = 1
expData.SnippetsFiltersDirectives = []string{"worker_priority-unknown"}
expData.SnippetsFiltersDirectivesCount = []int64{1}

data, err := dataCollector.Collect(ctx)

Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal(expData))
})
})
})
})

0 comments on commit 1404777

Please sign in to comment.