How to use DidTrackDeprecations method of types Package

Best Ginkgo code snippet using types.DidTrackDeprecations

node_test.go

Source:node_test.go Github

copy

Full Screen

...81 body = func() { didRun = true }82 })83 ExpectAllWell := func(errors []error) {84 ExpectWithOffset(1, errors).Should(BeEmpty())85 ExpectWithOffset(1, dt.DidTrackDeprecations()).Should(BeFalse())86 }87 Describe("happy path", func() {88 It("creates a node with a non-zero id", func() {89 node, errors := internal.NewNode(dt, ntIt, "text", body, cl, Focus, Label("A", "B", "C"))90 Ω(node.ID).Should(BeNumerically(">", 0))91 Ω(node.NodeType).Should(Equal(ntIt))92 Ω(node.Text).Should(Equal("text"))93 node.Body()94 Ω(didRun).Should(BeTrue())95 Ω(node.CodeLocation).Should(Equal(cl))96 Ω(node.MarkedFocus).Should(BeTrue())97 Ω(node.MarkedPending).Should(BeFalse())98 Ω(node.NestingLevel).Should(Equal(-1))99 Ω(node.Labels).Should(Equal(Labels{"A", "B", "C"}))100 ExpectAllWell(errors)101 })102 })103 Describe("Assigning CodeLocation", func() {104 Context("with nothing explicitly specified ", func() {105 It("assumes a base-offset of 2", func() {106 cl := types.NewCodeLocation(1)107 node, errors := internal.NewNode(dt, ntIt, "text", body)108 Ω(node.CodeLocation.FileName).Should(Equal(cl.FileName))109 ExpectAllWell(errors)110 })111 })112 Context("specifying code locations", func() {113 It("uses the last passed-in code location", func() {114 cl2 := types.NewCustomCodeLocation("hi")115 node, errors := internal.NewNode(dt, ntIt, "text", body, cl, cl2)116 Ω(node.CodeLocation).Should(Equal(cl2))117 ExpectAllWell(errors)118 })119 })120 Context("specifying offets", func() {121 It("takes the offset and adds it to the base-offset of 2 to compute the code location", func() {122 cl := types.NewCodeLocation(2)123 cl2 := types.NewCustomCodeLocation("hi")124 node, errors := internal.NewNode(dt, ntIt, "text", body, cl2, Offset(1))125 //note that Offset overrides cl2126 Ω(node.CodeLocation.FileName).Should(Equal(cl.FileName))127 ExpectAllWell(errors)128 })129 })130 })131 Describe("ignoring deprecated timeouts", func() {132 It("ignores any float64s", func() {133 node, errors := internal.NewNode(dt, ntIt, "text", body, 3.141, 2.71)134 node.Body()135 Ω(didRun).Should(BeTrue())136 ExpectAllWell(errors)137 })138 })139 Describe("the Focus and Pending decorations", func() {140 It("the node is neither Focused nor Pending by default", func() {141 node, errors := internal.NewNode(dt, ntIt, "text", body)142 Ω(node.MarkedFocus).Should(BeFalse())143 Ω(node.MarkedPending).Should(BeFalse())144 ExpectAllWell(errors)145 })146 It("marks the node as focused", func() {147 node, errors := internal.NewNode(dt, ntIt, "text", body, Focus)148 Ω(node.MarkedFocus).Should(BeTrue())149 Ω(node.MarkedPending).Should(BeFalse())150 ExpectAllWell(errors)151 })152 It("marks the node as pending", func() {153 node, errors := internal.NewNode(dt, ntIt, "text", body, Pending)154 Ω(node.MarkedFocus).Should(BeFalse())155 Ω(node.MarkedPending).Should(BeTrue())156 ExpectAllWell(errors)157 })158 It("errors when both Focus and Pending are set", func() {159 node, errors := internal.NewNode(dt, ntIt, "text", body, cl, Focus, Pending)160 Ω(node).Should(BeZero())161 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDeclarationOfFocusedAndPending(cl, ntIt)))162 })163 It("allows containers to be marked", func() {164 node, errors := internal.NewNode(dt, ntCon, "text", body, Focus)165 Ω(node.MarkedFocus).Should(BeTrue())166 Ω(node.MarkedPending).Should(BeFalse())167 ExpectAllWell(errors)168 node, errors = internal.NewNode(dt, ntCon, "text", body, Pending)169 Ω(node.MarkedFocus).Should(BeFalse())170 Ω(node.MarkedPending).Should(BeTrue())171 ExpectAllWell(errors)172 })173 It("does not allow non-container/it nodes to be marked", func() {174 node, errors := internal.NewNode(dt, ntBef, "", body, cl, Focus)175 Ω(node).Should(BeZero())176 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntBef, "Focus")))177 node, errors = internal.NewNode(dt, ntAf, "", body, cl, Pending)178 Ω(node).Should(BeZero())179 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntAf, "Pending")))180 Ω(dt.DidTrackDeprecations()).Should(BeFalse())181 })182 })183 Describe("the Serial decoration", func() {184 It("the node is not Serial by default", func() {185 node, errors := internal.NewNode(dt, ntIt, "text", body)186 Ω(node.MarkedSerial).Should(BeFalse())187 ExpectAllWell(errors)188 })189 It("marks the node as Serial", func() {190 node, errors := internal.NewNode(dt, ntIt, "text", body, Serial)191 Ω(node.MarkedSerial).Should(BeTrue())192 ExpectAllWell(errors)193 })194 It("allows containers to be marked", func() {195 node, errors := internal.NewNode(dt, ntCon, "text", body, Serial)196 Ω(node.MarkedSerial).Should(BeTrue())197 ExpectAllWell(errors)198 })199 It("does not allow non-container/it nodes to be marked", func() {200 node, errors := internal.NewNode(dt, ntBef, "", body, cl, Serial)201 Ω(node).Should(BeZero())202 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntBef, "Serial")))203 Ω(dt.DidTrackDeprecations()).Should(BeFalse())204 })205 })206 Describe("the Ordered decoration", func() {207 It("the node is not Ordered by default", func() {208 node, errors := internal.NewNode(dt, ntCon, "", body)209 Ω(node.MarkedOrdered).Should(BeFalse())210 ExpectAllWell(errors)211 })212 It("marks the node as Ordered", func() {213 node, errors := internal.NewNode(dt, ntCon, "", body, Ordered)214 Ω(node.MarkedOrdered).Should(BeTrue())215 ExpectAllWell(errors)216 })217 It("does not allow non-container nodes to be marked", func() {218 node, errors := internal.NewNode(dt, ntBef, "", body, cl, Ordered)219 Ω(node).Should(BeZero())220 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntBef, "Ordered")))221 Ω(dt.DidTrackDeprecations()).Should(BeFalse())222 node, errors = internal.NewNode(dt, ntIt, "not even Its", body, cl, Ordered)223 Ω(node).Should(BeZero())224 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntIt, "Ordered")))225 Ω(dt.DidTrackDeprecations()).Should(BeFalse())226 })227 })228 Describe("The FlakeAttempts decoration", func() {229 It("is zero by default", func() {230 node, errors := internal.NewNode(dt, ntIt, "text", body)231 Ω(node).ShouldNot(BeZero())232 Ω(node.FlakeAttempts).Should(Equal(0))233 ExpectAllWell(errors)234 })235 It("sets the FlakeAttempts field", func() {236 node, errors := internal.NewNode(dt, ntIt, "text", body, FlakeAttempts(2))237 Ω(node.FlakeAttempts).Should(Equal(2))238 ExpectAllWell(errors)239 })240 It("can be applied to containers", func() {241 node, errors := internal.NewNode(dt, ntCon, "text", body, FlakeAttempts(2))242 Ω(node.FlakeAttempts).Should(Equal(2))243 ExpectAllWell(errors)244 })245 It("cannot be applied to non-container/it nodes", func() {246 node, errors := internal.NewNode(dt, ntBef, "", body, cl, FlakeAttempts(2))247 Ω(node).Should(BeZero())248 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntBef, "FlakeAttempts")))249 Ω(dt.DidTrackDeprecations()).Should(BeFalse())250 })251 })252 Describe("The Label decoration", func() {253 It("has no labels by default", func() {254 node, errors := internal.NewNode(dt, ntIt, "text", body)255 Ω(node).ShouldNot(BeZero())256 Ω(node.Labels).Should(Equal(Labels{}))257 ExpectAllWell(errors)258 })259 It("can track labels", func() {260 node, errors := internal.NewNode(dt, ntIt, "text", body, Label("A", "B", "C"))261 Ω(node.Labels).Should(Equal(Labels{"A", "B", "C"}))262 ExpectAllWell(errors)263 })264 It("appends and dedupes all labels together, even if nested", func() {265 node, errors := internal.NewNode(dt, ntIt, "text", body, Label("A", "B", "C"), Label("D", "E", "C"), []interface{}{Label("F"), []interface{}{Label("G", "H", "A", "F")}})266 Ω(node.Labels).Should(Equal(Labels{"A", "B", "C", "D", "E", "F", "G", "H"}))267 ExpectAllWell(errors)268 })269 It("can be applied to containers", func() {270 node, errors := internal.NewNode(dt, ntCon, "text", body, Label("A", "B", "C"))271 Ω(node.Labels).Should(Equal(Labels{"A", "B", "C"}))272 ExpectAllWell(errors)273 })274 It("cannot be applied to non-container/it nodes", func() {275 node, errors := internal.NewNode(dt, ntBef, "", body, cl, Label("A", "B", "C"))276 Ω(node).Should(BeZero())277 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidDecoratorForNodeType(cl, ntBef, "Label")))278 Ω(dt.DidTrackDeprecations()).Should(BeFalse())279 })280 It("validates labels", func() {281 node, errors := internal.NewNode(dt, ntIt, "", body, cl, Label("A", "B&C", "C,D", "C,D ", " "))282 Ω(node).Should(BeZero())283 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidLabel("B&C", cl), types.GinkgoErrors.InvalidLabel("C,D", cl), types.GinkgoErrors.InvalidLabel("C,D ", cl), types.GinkgoErrors.InvalidEmptyLabel(cl)))284 Ω(dt.DidTrackDeprecations()).Should(BeFalse())285 })286 })287 Describe("passing in functions", func() {288 It("works when a single function is passed in", func() {289 node, errors := internal.NewNode(dt, ntIt, "text", body, cl)290 node.Body()291 Ω(didRun).Should(BeTrue())292 ExpectAllWell(errors)293 })294 It("allows deprecated async functions and registers a deprecation warning", func() {295 node, errors := internal.NewNode(dt, ntIt, "text", func(done Done) {296 didRun = true297 Ω(done).ShouldNot(BeNil())298 close(done)299 }, cl)300 node.Body()301 Ω(didRun).Should(BeTrue())302 Ω(errors).Should(BeEmpty())303 Ω(dt.DeprecationsReport()).Should(ContainSubstring(types.Deprecations.Async().Message))304 })305 It("errors if more than one function is provided", func() {306 node, errors := internal.NewNode(dt, ntIt, "text", body, body, cl)307 Ω(node).Should(BeZero())308 Ω(errors).Should(ConsistOf(types.GinkgoErrors.MultipleBodyFunctions(cl, ntIt)))309 Ω(dt.DidTrackDeprecations()).Should(BeFalse())310 })311 It("errors if the function has a return value", func() {312 f := func() string { return "" }313 node, errors := internal.NewNode(dt, ntIt, "text", f, cl)314 Ω(node).Should(BeZero())315 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidBodyType(reflect.TypeOf(f), cl, ntIt)))316 Ω(dt.DidTrackDeprecations()).Should(BeFalse())317 })318 It("errors if the function takes more than one argument", func() {319 f := func(Done, string) {}320 node, errors := internal.NewNode(dt, ntIt, "text", f, cl)321 Ω(node).Should(BeZero())322 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidBodyType(reflect.TypeOf(f), cl, ntIt)))323 Ω(dt.DidTrackDeprecations()).Should(BeFalse())324 })325 It("errors if the function takes one argument and that argument is not the deprecated Done channel", func() {326 f := func(chan interface{}) {}327 node, errors := internal.NewNode(dt, ntIt, "text", f, cl)328 Ω(node).Should(BeZero())329 Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidBodyType(reflect.TypeOf(f), cl, ntIt)))330 Ω(dt.DidTrackDeprecations()).Should(BeFalse())331 })332 It("errors if no function is passed in", func() {333 node, errors := internal.NewNode(dt, ntIt, "text", cl)334 Ω(node).Should(BeZero())335 Ω(errors).Should(ConsistOf(types.GinkgoErrors.MissingBodyFunction(cl, ntIt)))336 Ω(dt.DidTrackDeprecations()).Should(BeFalse())337 })338 It("is ok if no function is passed in but it is marked pending", func() {339 node, errors := internal.NewNode(dt, ntIt, "text", cl, Pending)340 Ω(node.IsZero()).Should(BeFalse())341 ExpectAllWell(errors)342 })343 })344 Describe("non-recognized decorations", func() {345 It("errors when a non-recognized decoration is provided", func() {346 node, errors := internal.NewNode(dt, ntIt, "text", cl, body, Focus, "aardvark", 5)347 Ω(node).Should(BeZero())348 Ω(errors).Should(ConsistOf(349 types.GinkgoErrors.UnknownDecorator(cl, ntIt, "aardvark"),350 types.GinkgoErrors.UnknownDecorator(cl, ntIt, 5),351 ))352 Ω(dt.DidTrackDeprecations()).Should(BeFalse())353 })354 })355 Describe("when decorations are nested in slices", func() {356 It("unrolls them first", func() {357 node, errors := internal.NewNode(dt, ntIt, "text", []interface{}{body, []interface{}{Focus, FlakeAttempts(3), Label("A")}, FlakeAttempts(2), Label("B"), Label("C", "D")})358 Ω(node.FlakeAttempts).Should(Equal(2))359 Ω(node.MarkedFocus).Should(BeTrue())360 Ω(node.Labels).Should(Equal(Labels{"A", "B", "C", "D"}))361 node.Body()362 Ω(didRun).Should(BeTrue())363 ExpectAllWell(errors)364 })365 })366})...

Full Screen

Full Screen

deprecated_support_test.go

Source:deprecated_support_test.go Github

copy

Full Screen

...19 formatter.SingletonFormatter.ColorMode = formatter.ColorModeTerminal20 })21 Context("with no tracked deprecations", func() {22 It("reports no tracked deprecations", func() {23 Ω(tracker.DidTrackDeprecations()).Should(BeFalse())24 })25 })26 Context("with tracked dependencies", func() {27 BeforeEach(func() {28 tracker.TrackDeprecation(types.Deprecation{29 Message: "Deprecation 1",30 DocLink: "doclink-1",31 }, types.CodeLocation{FileName: "foo.go", LineNumber: 17})32 tracker.TrackDeprecation(types.Deprecation{33 Message: "Deprecation 1",34 DocLink: "doclink-1",35 }, types.CodeLocation{FileName: "bar.go", LineNumber: 30})36 tracker.TrackDeprecation(types.Deprecation{37 Message: "Deprecation 2",38 DocLink: "doclink-2",39 })40 tracker.TrackDeprecation(types.Deprecation{41 Message: "Deprecation 3",42 }, types.CodeLocation{FileName: "baz.go", LineNumber: 72})43 })44 It("reports tracked deprecations", func() {45 Ω(tracker.DidTrackDeprecations()).Should(BeTrue())46 })47 It("generates a nicely formatted report", func() {48 report := tracker.DeprecationsReport()49 Ω(report).Should(HavePrefix("{{light-yellow}}You're using deprecated Ginkgo functionality:{{/}}\n{{light-yellow}}============================================={{/}}\n"))50 Ω(report).Should(ContainSubstring(strings.Join([]string{51 " {{yellow}}Deprecation 1{{/}}",52 " {{bold}}Learn more at:{{/}} {{cyan}}{{underline}}https://onsi.github.io/ginkgo/MIGRATING_TO_V2#doclink-1{{/}}",53 " {{gray}}foo.go:17{{/}}",54 " {{gray}}bar.go:30{{/}}",55 "",56 }, "\n")))57 Ω(report).Should(ContainSubstring(strings.Join([]string{58 " {{yellow}}Deprecation 2{{/}}",59 " {{bold}}Learn more at:{{/}} {{cyan}}{{underline}}https://onsi.github.io/ginkgo/MIGRATING_TO_V2#doclink-2{{/}}",...

Full Screen

Full Screen

DidTrackDeprecations

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fset := token.NewFileSet()4 f, err := parser.ParseFile(fset, "1.go", nil, 0)5 if err != nil {6 log.Fatal(err)7 }8 conf := types.Config{9 Importer: importerFor(&conf, "src"),10 }11 info := &types.Info{12 Defs: make(map[*ast.Ident]types.Object),13 Uses: make(map[*ast.Ident]types.Object),14 }15 _, err = conf.Check("cmd/godoc", fset, []*ast.File{f}, info)16 if err != nil {17 log.Fatal(err)18 }19 fmt.Println(info.DidTrackDeprecations())20 fmt.Println(info.Dependencies())21 fmt.Println(info.Types)

Full Screen

Full Screen

DidTrackDeprecations

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 info := types.Info{4 Deprecations: map[*types.Object][]types.Deprecation{},5 }6 conf := types.Config{Importer: importer.Default()}7 pkg, _ := conf.Check("example.com/pkg", fset, []*ast.File{f}, &info)8 if info.DidTrackDeprecations() {9 fmt.Println("Deprecations were tracked.")10 }11}

Full Screen

Full Screen

DidTrackDeprecations

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4}5import (6type Block struct {7}8type Header struct {9}10func (b *Block) DidTrackDeprecations() bool {11 fmt.Println("Hello, playground")12}13import (14type Block struct {15}16type Header struct {17}18func (b *Block) DidTrackDeprecations() bool {19 fmt.Println("Hello, playground")20}21import (22type Block struct {23}24type Header struct {25}26func (b *Header) DidTrackDeprecations() bool {27 fmt.Println("Hello, playground")28}29import (30type Block struct {31}32type Header struct {33}34func (b *Header) DidTrackDeprecations() bool {35 fmt.Println("Hello, playground")36}37import (38type Block struct {39}40type Header struct {41}42func (b *Header) DidTrackDeprecations() bool {43 fmt.Println("Hello, playground")44}45import (46type Block struct {47}48type Header struct {49}50func (b *Header) DidTrackDeprecations() bool {51 fmt.Println("Hello, playground")52}53import (54type Block struct {55}56type Header struct {57}58func (b *Header) DidTrackDeprecations() bool {59 fmt.Println("Hello, playground")60}

Full Screen

Full Screen

DidTrackDeprecations

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cfg := types.Config{4 }5 info := types.Info{6 }7 importer := types.StdImporter{8 }9 importerFrom := types.StdImporterFrom{10 }11 checker := types.Checker{12 }13 info1 := types.Info{14 }15 cfg1 := types.Config{16 }17 fmt.Println("DidTrackDeprecations of types.Config object: ", cfg.DidTrackDeprecations())18 fmt.Println("DidTrackDeprecations of types.Info object: ", info.DidTrackDeprecations())19 fmt.Println("DidTrackDeprecations of types.StdImporter object: ", importer.DidTrackDeprecations())

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Ginkgo automation tests on LambdaTest cloud grid

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

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful