Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
Signed-off-by: FlamingSaint <[email protected]>
  • Loading branch information
FlamingSaint committed Jul 22, 2024
1 parent 060740b commit 8f0ee2b
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cmd/jaeger/internal/extension/jaegerquery/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,51 @@ func TestServerAddArchiveStorage(t *testing.T) {
})
}
}

func TestServerAddMetricsStorage(t *testing.T) {
host := componenttest.NewNopHost()

tests := []struct {
name string
config *Config
extension component.Component
expectedOutput string
expectedErr string
}{
{
name: "Metrics storage unset",
config: &Config{},
expectedOutput: `{"level":"info","msg":"Metric storage not configured"}` + "\n",
expectedErr: "",
},
{
name: "Metrics storage set",
config: &Config{
MetricStorage: "random-value",
},
expectedOutput: "",
expectedErr: "cannot find metrics storage factory: cannot find extension",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
logger, buf := testutils.NewLogger()
telemetrySettings := component.TelemetrySettings{
Logger: logger,
}
server := newServer(tt.config, telemetrySettings)
if tt.extension != nil {
host = storagetest.NewStorageHost().WithExtension(jaegerstorage.ID, tt.extension)
}
_, err := server.createMetricStorage(host)
if tt.expectedErr == "" {
require.NoError(t, err)
} else {
require.ErrorContains(t, err, tt.expectedErr)
}

assert.Contains(t, buf.String(), tt.expectedOutput)
})
}
}

0 comments on commit 8f0ee2b

Please sign in to comment.