File: nondeterministic_fixture_suite_test.go

package info (click to toggle)
golang-github-onsi-ginkgo-v2 2.22.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,060 kB
  • sloc: javascript: 59; makefile: 23; sh: 14
file content (36 lines) | stat: -rw-r--r-- 941 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package nondeterministic_fixture_test

import (
	"strings"
	"testing"

	. "github.com/onsi/ginkgo/v2"
	"github.com/onsi/ginkgo/v2/types"
	. "github.com/onsi/gomega"
)

func TestNondeterministicFixture(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "NondeterministicFixture Suite")
}

var _ = ReportAfterSuite("ensure all specs ran correctly", func(report types.Report) {
	specs := report.SpecReports.WithLeafNodeType(types.NodeTypeIt)
	orderedTexts := []string{}
	textCounts := map[string]int{}
	for _, spec := range specs {
		text := spec.FullText()
		textCounts[text] += 1
		if strings.HasPrefix(text, "ordered") {
			orderedTexts = append(orderedTexts, spec.LeafNodeText)
		}
	}

	By("ensuring there are no duplicates")
	for text, count := range textCounts {
		Ω(count).Should(Equal(1), text)
	}

	By("ensuring ordered specs are strictly preserved")
	Ω(orderedTexts).Should(Equal([]string{"always", "runs", "in", "order"}))
})