mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
tests: remove err from message when testify prints it already
For instance `require.NoError` will print the unexpected error; we don't need to include it in the message. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
1a47c7d59b
commit
16e68c01e4
|
@ -73,6 +73,6 @@ Loop:
|
|||
require.Error(t, err, "prometheus didn't shutdown gracefully after sending the Interrupt signal")
|
||||
// TODO - find a better way to detect when the process didn't exit as expected!
|
||||
if stoppedErr != nil {
|
||||
require.EqualError(t, stoppedErr, "signal: interrupt", "prometheus exited with an unexpected error: %v", stoppedErr)
|
||||
require.EqualError(t, stoppedErr, "signal: interrupt", "prometheus exit")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3480,7 +3480,7 @@ func testQuerierShouldNotPanicIfHeadChunkIsTruncatedWhileReadingQueriedChunks(t
|
|||
// when the iterator tries to fetch an head chunk which has been offloaded because
|
||||
// of the head compaction in the meanwhile.
|
||||
if firstErr != nil {
|
||||
require.ErrorContains(t, firstErr, "cannot populate chunk", "unexpected error: %s", firstErr.Error())
|
||||
require.ErrorContains(t, firstErr, "cannot populate chunk")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@ func TestLocking(t *testing.T) {
|
|||
require.Error(t, err, "File %q unexpectedly exists.", fileName)
|
||||
|
||||
lock, existed, err := Flock(fileName)
|
||||
require.NoError(t, err, "Error locking file %q: %s", fileName, err)
|
||||
require.NoError(t, err, "Error locking file %q", fileName)
|
||||
require.False(t, existed, "File %q reported as existing during locking.", fileName)
|
||||
|
||||
// File must now exist.
|
||||
_, err = os.Stat(fileName)
|
||||
require.NoError(t, err, "Could not stat file %q expected to exist: %s", fileName, err)
|
||||
require.NoError(t, err, "Could not stat file %q expected to exist", fileName)
|
||||
|
||||
// Try to lock again.
|
||||
lockedAgain, existed, err := Flock(fileName)
|
||||
|
@ -47,17 +47,17 @@ func TestLocking(t *testing.T) {
|
|||
require.True(t, existed, "Existing file %q not recognized.", fileName)
|
||||
|
||||
err = lock.Release()
|
||||
require.NoError(t, err, "Error releasing lock for file %q: %s", fileName, err)
|
||||
require.NoError(t, err, "Error releasing lock for file %q", fileName)
|
||||
|
||||
// File must still exist.
|
||||
_, err = os.Stat(fileName)
|
||||
require.NoError(t, err, "Could not stat file %q expected to exist: %s", fileName, err)
|
||||
require.NoError(t, err, "Could not stat file %q expected to exist", fileName)
|
||||
|
||||
// Lock existing file.
|
||||
lock, existed, err = Flock(fileName)
|
||||
require.NoError(t, err, "Error locking file %q: %s", fileName, err)
|
||||
require.NoError(t, err, "Error locking file %q", fileName)
|
||||
require.True(t, existed, "Existing file %q not recognized.", fileName)
|
||||
|
||||
err = lock.Release()
|
||||
require.NoError(t, err, "Error releasing lock for file %q: %s", fileName, err)
|
||||
require.NoError(t, err, "Error releasing lock for file %q", fileName)
|
||||
}
|
||||
|
|
|
@ -3084,7 +3084,7 @@ func TestClose(t *testing.T) {
|
|||
createBlock(t, dir, genSeries(1, 1, 10, 20))
|
||||
|
||||
db, err := Open(dir, nil, nil, DefaultOptions(), nil)
|
||||
require.NoError(t, err, "Opening test storage failed: %s", err)
|
||||
require.NoError(t, err, "Opening test storage failed: %s")
|
||||
defer func() {
|
||||
require.NoError(t, db.Close())
|
||||
}()
|
||||
|
|
|
@ -186,10 +186,9 @@ func TestReader(t *testing.T) {
|
|||
require.Equal(t, c.exp[j], rec, "Bytes within record did not match expected Bytes")
|
||||
}
|
||||
if !c.fail {
|
||||
require.NoError(t, r.Err(), "unexpected error: %s", r.Err())
|
||||
}
|
||||
if c.fail {
|
||||
require.Error(t, r.Err(), "expected error but got none")
|
||||
require.NoError(t, r.Err())
|
||||
} else {
|
||||
require.Error(t, r.Err())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ func (m *rulesRetrieverMock) CreateRuleGroups() {
|
|||
}
|
||||
|
||||
recordingExpr, err := parser.ParseExpr(`vector(1)`)
|
||||
require.NoError(m.testing, err, "unable to parse alert expression: %s", err)
|
||||
require.NoError(m.testing, err, "unable to parse alert expression")
|
||||
recordingRule := rules.NewRecordingRule("recording-rule-1", recordingExpr, labels.Labels{})
|
||||
r = append(r, recordingRule)
|
||||
|
||||
|
@ -3238,10 +3238,10 @@ func TestRespondError(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
resp, err := http.Get(s.URL)
|
||||
require.NoError(t, err, "Error on test request: %s", err)
|
||||
require.NoError(t, err, "Error on test request")
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
require.NoError(t, err, "Error reading response body: %s", err)
|
||||
require.NoError(t, err, "Error reading response body")
|
||||
want, have := http.StatusServiceUnavailable, resp.StatusCode
|
||||
require.Equal(t, want, have, "Return code %d expected in error response but got %d", want, have)
|
||||
h := resp.Header.Get("Content-Type")
|
||||
|
@ -3249,7 +3249,7 @@ func TestRespondError(t *testing.T) {
|
|||
|
||||
var res Response
|
||||
err = json.Unmarshal(body, &res)
|
||||
require.NoError(t, err, "Error unmarshaling JSON body: %s", err)
|
||||
require.NoError(t, err, "Error unmarshaling JSON body")
|
||||
|
||||
exp := &Response{
|
||||
Status: statusError,
|
||||
|
@ -3379,7 +3379,7 @@ func TestParseTime(t *testing.T) {
|
|||
for _, test := range tests {
|
||||
ts, err := parseTime(test.input)
|
||||
if !test.fail {
|
||||
require.NoError(t, err, "Unexpected error for %q: %s", test.input, err)
|
||||
require.NoError(t, err, "Unexpected error for %q", test.input)
|
||||
require.NotNil(t, ts)
|
||||
require.True(t, ts.Equal(test.result), "Expected time %v for input %q but got %v", test.result, test.input, ts)
|
||||
continue
|
||||
|
@ -3429,7 +3429,7 @@ func TestParseDuration(t *testing.T) {
|
|||
for _, test := range tests {
|
||||
d, err := parseDuration(test.input)
|
||||
if !test.fail {
|
||||
require.NoError(t, err, "Unexpected error for %q: %s", test.input, err)
|
||||
require.NoError(t, err, "Unexpected error for %q", test.input)
|
||||
require.Equal(t, test.result, d, "Expected duration %v for input %q but got %v", test.result, test.input, d)
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue