Skip to content

Commit

Permalink
chore: use testify instead of t.Fatal (#6162)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorel-35 authored Nov 4, 2024
1 parent c65757f commit 0a24f6d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
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

0 comments on commit 0a24f6d

Please sign in to comment.