test cases for array
(t *testing.T)
| 536 | |
| 537 | // test cases for array |
| 538 | func TestSpansetOperationEvaluateArray(t *testing.T) { |
| 539 | testCases := []evalTC{ |
| 540 | // string arrays |
| 541 | { |
| 542 | "{ .foo = `bar` }", // match string array |
| 543 | []*Spanset{ |
| 544 | {Spans: []Span{ |
| 545 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "baz"})}}, |
| 546 | &mockSpan{id: []byte{2}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticString("b")}}, |
| 547 | }}, |
| 548 | }, |
| 549 | []*Spanset{ |
| 550 | {Spans: []Span{ |
| 551 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "baz"})}}, |
| 552 | }}, |
| 553 | }, |
| 554 | }, |
| 555 | { |
| 556 | "{ .foo = `bar` || .bat = `baz` }", // match string array with or |
| 557 | []*Spanset{ |
| 558 | {Spans: []Span{ |
| 559 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "baz"})}}, |
| 560 | &mockSpan{id: []byte{2}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticString("b")}}, |
| 561 | }}, |
| 562 | }, |
| 563 | []*Spanset{ |
| 564 | {Spans: []Span{ |
| 565 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "baz"})}}, |
| 566 | }}, |
| 567 | }, |
| 568 | }, |
| 569 | { |
| 570 | "{ .foo != `baz` }", // match string not in array |
| 571 | []*Spanset{ |
| 572 | {Spans: []Span{ |
| 573 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "bla"})}}, |
| 574 | &mockSpan{id: []byte{2}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"baz"})}}, |
| 575 | }}, |
| 576 | }, |
| 577 | []*Spanset{ |
| 578 | {Spans: []Span{ |
| 579 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "bla"})}}, |
| 580 | }}, |
| 581 | }, |
| 582 | }, |
| 583 | { |
| 584 | "{ .foo =~ `ba.*` }", // match string array with regex |
| 585 | []*Spanset{ |
| 586 | {Spans: []Span{ |
| 587 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "baz"})}}, |
| 588 | &mockSpan{id: []byte{2}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"foo", "baz"})}}, |
| 589 | &mockSpan{id: []byte{3}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"dog", "cat"})}}, |
| 590 | }}, |
| 591 | }, |
| 592 | []*Spanset{ |
| 593 | {Spans: []Span{ |
| 594 | &mockSpan{id: []byte{1}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"bar", "baz"})}}, |
| 595 | &mockSpan{id: []byte{2}, attributes: map[Attribute]Static{NewAttribute("foo"): NewStaticStringArray([]string{"foo", "baz"})}}, |
nothing calls this directly
no test coverage detected