How to use CL method of internal_test Package

Best Ginkgo code snippet using internal_test.CL

Run Ginkgo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

prefetch_test.go

Source: prefetch_test.go Github

copy
1package internal_test
2
3import (
4	"github.com/stretchr/testify/assert"
5	"github.com/wal-g/wal-g/internal"
6	"testing"
7)
8
9type MockCleaner struct {
10	deleted []string
11}
12
13func (cl *MockCleaner) GetFiles(directory string) (files []string, err error) {
14	files = []string{
15		"000000010000000100000056",
16		"000000010000000100000057",
17		"000000010000000100000058",
18		"000000010000000100000059",
19		"00000001000000010000005A",
20	}
21	return
22}
23
24func (cl *MockCleaner) Remove(file string) {
25	cl.deleted = append(cl.deleted, file)
26}
27
28func TestCleanup(t *testing.T) {
29	cleaner := MockCleaner{}
30	internal.CleanupPrefetchDirectories("000000010000000100000058", "/A", &cleaner)
31
32	assert.NotContains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000058")
33	assert.NotContains(t, cleaner.deleted, "/A/.wal-g/prefetch/running/000000010000000100000059")
34	assert.NotContains(t, cleaner.deleted, "/A/.wal-g/prefetch/00000001000000010000005A")
35
36	assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
37	assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
38	assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
39	assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
40}
41
Full Screen

failer_test.go

Source: failer_test.go Github

copy
1package internal_test
2
3import (
4	. "github.com/onsi/ginkgo/v2"
5	"github.com/onsi/ginkgo/v2/internal"
6	"github.com/onsi/ginkgo/v2/types"
7	. "github.com/onsi/gomega"
8)
9
10var _ = Describe("Failer", func() {
11	var failer *internal.Failer
12	var clA types.CodeLocation
13	var clB types.CodeLocation
14
15	BeforeEach(func() {
16		clA = CL("file_a.go")
17		clB = CL("file_b.go")
18		failer = internal.NewFailer()
19	})
20
21	Context("with no failures", func() {
22		It("should return success when drained", func() {
23			state, failure := failer.Drain()
24			Ω(state).Should(Equal(types.SpecStatePassed))
25			Ω(failure).Should(BeZero())
26		})
27	})
28
29	Describe("when told of a failure", func() {
30		BeforeEach(func() {
31			failer.Fail("something failed", clA)
32		})
33
34		It("should record the failure", func() {
35			state, failure := failer.Drain()
36			Ω(state).Should(Equal(types.SpecStateFailed))
37			Ω(failure).Should(Equal(types.Failure{
38				Message:  "something failed",
39				Location: clA,
40			}))
41		})
42
43		Context("when told of anotehr failure", func() {
44			It("discards the second failure, preserving the original", func() {
45				failer.Fail("something else failed", clB)
46
47				state, failure := failer.Drain()
48				Ω(state).Should(Equal(types.SpecStateFailed))
49				Ω(failure).Should(Equal(types.Failure{
50					Message:  "something failed",
51					Location: clA,
52				}))
53			})
54		})
55	})
56
57	Describe("when told to skip", func() {
58		Context("when no failure has occured", func() {
59			It("registers the test as skipped", func() {
60				failer.Skip("something skipped", clA)
61				state, failure := failer.Drain()
62				Ω(state).Should(Equal(types.SpecStateSkipped))
63				Ω(failure).Should(Equal(types.Failure{
64					Message:  "something skipped",
65					Location: clA,
66				}))
67			})
68		})
69
70		Context("when a failure has already occured", func() {
71			BeforeEach(func() {
72				failer.Fail("something failed", clA)
73			})
74
75			It("does not modify the failure", func() {
76				failer.Skip("something skipped", clB)
77				state, failure := failer.Drain()
78				Ω(state).Should(Equal(types.SpecStateFailed))
79				Ω(failure).Should(Equal(types.Failure{
80					Message:  "something failed",
81					Location: clA,
82				}))
83			})
84		})
85	})
86
87	Describe("when told to abort", func() {
88		Context("when no failure has occured", func() {
89			It("registers the test as aborted", func() {
90				failer.AbortSuite("something aborted", clA)
91				state, failure := failer.Drain()
92				Ω(state).Should(Equal(types.SpecStateAborted))
93				Ω(failure).Should(Equal(types.Failure{
94					Message:  "something aborted",
95					Location: clA,
96				}))
97			})
98		})
99
100		Context("when a failure has already occured", func() {
101			BeforeEach(func() {
102				failer.Fail("something failed", clA)
103			})
104
105			It("does not modify the failure", func() {
106				failer.AbortSuite("something aborted", clA)
107				state, failure := failer.Drain()
108				Ω(state).Should(Equal(types.SpecStateFailed))
109				Ω(failure).Should(Equal(types.Failure{
110					Message:  "something failed",
111					Location: clA,
112				}))
113			})
114		})
115	})
116
117	Describe("when told to panic", func() {
118		BeforeEach(func() {
119			failer.Panic(clA, 17)
120		})
121
122		It("should record the panic", func() {
123			state, failure := failer.Drain()
124			Ω(state).Should(Equal(types.SpecStatePanicked))
125			Ω(failure).Should(Equal(types.Failure{
126				Message:        "Test Panicked",
127				Location:       clA,
128				ForwardedPanic: "17",
129			}))
130		})
131
132		Context("when told of another panic", func() {
133			It("discards the second panic, preserving the original", func() {
134				failer.Panic(clB, 23)
135
136				state, failure := failer.Drain()
137				Ω(state).Should(Equal(types.SpecStatePanicked))
138				Ω(failure).Should(Equal(types.Failure{
139					Message:        "Test Panicked",
140					Location:       clA,
141					ForwardedPanic: "17",
142				}))
143			})
144		})
145	})
146
147	Context("when drained", func() {
148		BeforeEach(func() {
149			failer.Fail("something failed", clA)
150			state, _ := failer.Drain()
151			Ω(state).Should(Equal(types.SpecStateFailed))
152		})
153
154		It("resets the failer such that subsequent drains pass", func() {
155			state, failure := failer.Drain()
156			Ω(state).Should(Equal(types.SpecStatePassed))
157			Ω(failure).Should(BeZero())
158		})
159
160		It("allows subsequent failures to be recorded", func() {
161			failer.Fail("something else failed", clB)
162			state, failure := failer.Drain()
163			Ω(state).Should(Equal(types.SpecStateFailed))
164			Ω(failure).Should(Equal(types.Failure{
165				Message:  "something else failed",
166				Location: clB,
167			}))
168		})
169	})
170})
171
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger CL code on LambdaTest Cloud Grid

Execute automation tests with CL on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)