(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func TestValidateTraceRetrieval(t *testing.T) { |
| 82 | tests := []struct { |
| 83 | name string |
| 84 | queryError error |
| 85 | traceResponse *tempopb.Trace |
| 86 | expectError bool |
| 87 | }{ |
| 88 | { |
| 89 | name: "successful retrieval", |
| 90 | // We'll create matching trace ID dynamically |
| 91 | traceResponse: &tempopb.Trace{ |
| 92 | ResourceSpans: []*v1.ResourceSpans{ |
| 93 | { |
| 94 | ScopeSpans: []*v1.ScopeSpans{ |
| 95 | { |
| 96 | Spans: []*v1.Span{ |
| 97 | { |
| 98 | // TraceId will be set dynamically to match |
| 99 | Name: "test-span", |
| 100 | }, |
| 101 | }, |
| 102 | }, |
| 103 | }, |
| 104 | }, |
| 105 | }, |
| 106 | }, |
| 107 | expectError: false, |
| 108 | }, |
| 109 | { |
| 110 | name: "query error", |
| 111 | queryError: errors.New("query failed"), |
| 112 | expectError: true, |
| 113 | }, |
| 114 | { |
| 115 | name: "empty trace spans", |
| 116 | traceResponse: &tempopb.Trace{ |
| 117 | ResourceSpans: []*v1.ResourceSpans{}, // Empty! |
| 118 | }, |
| 119 | expectError: true, |
| 120 | }, |
| 121 | } |
| 122 | |
| 123 | for _, tt := range tests { |
| 124 | t.Run(tt.name, func(t *testing.T) { |
| 125 | // Create a TraceInfo |
| 126 | mockClock := &MockClock{ |
| 127 | now: time.Date(2025, 1, 1, 12, 0, 0, 0, time.UTC), |
| 128 | } |
| 129 | |
| 130 | vs := &ValidationService{ |
| 131 | config: ValidationConfig{TempoOrgID: "test-org"}, |
| 132 | clock: mockClock, |
| 133 | logger: zap.NewNop(), |
| 134 | } |
| 135 | |
| 136 | traceInfo := util.NewTraceInfo(mockClock.Now(), "test-org") |
| 137 | |
| 138 | // Set matching trace ID in the mock response |
nothing calls this directly
no test coverage detected