Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use testify instead of t.Fatal #6162

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions cmd/agent/app/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func TestAgentSamplingEndpoint(t *testing.T) {
}
select {
case err := <-errorch:
if err != nil {
t.Fatalf("error from agent: %s", err)
}
require.NoError(t, err, "error from agent")
break wait_loop
default:
time.Sleep(time.Millisecond)
Expand Down Expand Up @@ -155,9 +153,7 @@ func TestStartStopRace(t *testing.T) {
// Before the bug was fixed this test was failing as expected when
// run with -race flag.

if err := agent.Run(); err != nil {
t.Fatalf("error from agent.Run(): %s", err)
}
require.NoError(t, agent.Run())

t.Log("stopping agent")
agent.Stop()
Expand Down Expand Up @@ -192,9 +188,7 @@ func TestStartStopWithSocketBufferSet(t *testing.T) {
agent, err := cfg.CreateAgent(fakeCollectorProxy{}, zap.NewNop(), metricsFactory)
require.NoError(t, err)

if err := agent.Run(); err != nil {
t.Fatalf("error from agent.Run(): %s", err)
}
require.NoError(t, agent.Run())

t.Log("stopping agent")
agent.Stop()
Expand Down
4 changes: 1 addition & 3 deletions internal/metrics/prometheus/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,7 @@ func findMetric(t *testing.T, snapshot []*promModel.MetricFamily, name string, t
continue
}
for _, m := range mf.GetMetric() {
if len(m.GetLabel()) != len(tags) {
t.Fatalf("Mismatching labels for metric %v: want %v, have %v", name, tags, m.GetLabel())
}
require.Lenf(t, m.GetLabel(), len(tags), "Mismatching labels for metric %v: want %v, have %v", name, tags, m.GetLabel())
match := true
for _, l := range m.GetLabel() {
if v, ok := tags[l.GetName()]; !ok || v != l.GetValue() {
Expand Down
4 changes: 1 addition & 3 deletions pkg/gogocodec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ func BenchmarkCodecUnmarshal25Spans(b *testing.B) {
for i := 0; i < b.N; i++ {
var trace model.Trace
err := c.Unmarshal(bytes, &trace)
if err != nil {
b.Fatal(err)
}
require.NoError(b, err)
}
}

Expand Down
8 changes: 2 additions & 6 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ func healthCheck() error {

func testElasticsearchStorage(t *testing.T, allTagsAsFields bool) {
SkipUnlessEnv(t, "elasticsearch", "opensearch")
if err := healthCheck(); err != nil {
t.Fatal(err)
}
require.NoError(t, healthCheck())
s := &ESStorageIntegration{
StorageIntegration: StorageIntegration{
Fixtures: LoadAndParseQueryTestCases(t, "fixtures/queries_es.json"),
Expand All @@ -182,9 +180,7 @@ func TestElasticsearchStorage_AllTagsAsObjectFields(t *testing.T) {

func TestElasticsearchStorage_IndexTemplates(t *testing.T) {
SkipUnlessEnv(t, "elasticsearch", "opensearch")
if err := healthCheck(); err != nil {
t.Fatal(err)
}
require.NoError(t, healthCheck())
s := &ESStorageIntegration{}
s.initializeES(t, true)
esVersion, err := s.getVersion()
Expand Down
Loading