mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
test: fix use of t.Logf
where t.Log
would suffice (#16328)
This commit is contained in:
committed by
GitHub
parent
6caa29a29f
commit
c069563af1
@ -66,7 +66,7 @@ func TestDeleteOldWorkspaceAgentStats(t *testing.T) {
|
||||
|
||||
defer func() {
|
||||
if t.Failed() {
|
||||
t.Logf("Test failed, printing rows...")
|
||||
t.Log("Test failed, printing rows...")
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
buf := &bytes.Buffer{}
|
||||
enc := json.NewEncoder(buf)
|
||||
|
@ -283,9 +283,9 @@ func TestMigrateUpWithFixtures(t *testing.T) {
|
||||
}
|
||||
}
|
||||
if len(emptyTables) > 0 {
|
||||
t.Logf("The following tables have zero rows, consider adding fixtures for them or create a full database dump:")
|
||||
t.Log("The following tables have zero rows, consider adding fixtures for them or create a full database dump:")
|
||||
t.Errorf("tables have zero rows: %v", emptyTables)
|
||||
t.Logf("See https://github.com/coder/coder/blob/main/docs/CONTRIBUTING.md#database-fixtures-for-testing-migrations for more information")
|
||||
t.Log("See https://github.com/coder/coder/blob/main/docs/CONTRIBUTING.md#database-fixtures-for-testing-migrations for more information")
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -388,7 +388,7 @@ func TestBackpressure(t *testing.T) {
|
||||
}, testutil.WaitShort, testutil.IntervalFast)
|
||||
}
|
||||
}
|
||||
t.Logf("done advancing")
|
||||
t.Log("done advancing")
|
||||
// The batch completes
|
||||
w.MustWait(ctx)
|
||||
|
||||
|
@ -547,8 +547,8 @@ func TestAcquirer_MatchTags(t *testing.T) {
|
||||
s := fmt.Sprintf("| %s | %s | %s | %s |", kvs(tt.acquireJobTags), kvs(tt.provisionerJobTags), sameOrg, acquire)
|
||||
lines = append(lines, s)
|
||||
}
|
||||
t.Logf("You can paste this into docs/admin/provisioners.md")
|
||||
t.Logf(strings.Join(lines, "\n"))
|
||||
t.Log("You can paste this into docs/admin/provisioners.md")
|
||||
t.Log(strings.Join(lines, "\n"))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ func TestHeartbeat(t *testing.T) {
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
heartbeatChan := make(chan struct{})
|
||||
heartbeatFn := func(hbCtx context.Context) error {
|
||||
t.Logf("heartbeat")
|
||||
t.Log("heartbeat")
|
||||
select {
|
||||
case <-hbCtx.Done():
|
||||
return hbCtx.Err()
|
||||
|
@ -53,7 +53,7 @@ func TestBatchStats(t *testing.T) {
|
||||
tick <- t1
|
||||
f := <-flushed
|
||||
require.Equal(t, 0, f, "expected no data to be flushed")
|
||||
t.Logf("flush 1 completed")
|
||||
t.Log("flush 1 completed")
|
||||
|
||||
// Then: it should report no stats.
|
||||
stats, err := store.GetWorkspaceAgentStats(ctx, t1)
|
||||
@ -62,7 +62,7 @@ func TestBatchStats(t *testing.T) {
|
||||
|
||||
// Given: a single data point is added for workspace
|
||||
t2 := t1.Add(time.Second)
|
||||
t.Logf("inserting 1 stat")
|
||||
t.Log("inserting 1 stat")
|
||||
b.Add(t2.Add(time.Millisecond), deps1.Agent.ID, deps1.User.ID, deps1.Template.ID, deps1.Workspace.ID, randStats(t), false)
|
||||
|
||||
// When: it becomes time to report stats
|
||||
@ -70,7 +70,7 @@ func TestBatchStats(t *testing.T) {
|
||||
tick <- t2
|
||||
f = <-flushed // Wait for a flush to complete.
|
||||
require.Equal(t, 1, f, "expected one stat to be flushed")
|
||||
t.Logf("flush 2 completed")
|
||||
t.Log("flush 2 completed")
|
||||
|
||||
// Then: it should report a single stat.
|
||||
stats, err = store.GetWorkspaceAgentStats(ctx, t2)
|
||||
@ -97,7 +97,7 @@ func TestBatchStats(t *testing.T) {
|
||||
// When: the buffer comes close to capacity
|
||||
// Then: The buffer will force-flush once.
|
||||
f = <-flushed
|
||||
t.Logf("flush 3 completed")
|
||||
t.Log("flush 3 completed")
|
||||
require.Greater(t, f, 819, "expected at least 819 stats to be flushed (>=80% of buffer)")
|
||||
// And we should finish inserting the stats
|
||||
<-done
|
||||
@ -110,7 +110,7 @@ func TestBatchStats(t *testing.T) {
|
||||
t4 := t3.Add(time.Second)
|
||||
tick <- t4
|
||||
f2 := <-flushed
|
||||
t.Logf("flush 4 completed")
|
||||
t.Log("flush 4 completed")
|
||||
expectedCount := defaultBufferSize - f
|
||||
require.Equal(t, expectedCount, f2, "did not flush expected remaining rows")
|
||||
|
||||
@ -119,7 +119,7 @@ func TestBatchStats(t *testing.T) {
|
||||
tick <- t5
|
||||
f = <-flushed
|
||||
require.Zero(t, f, "expected zero stats to have been flushed")
|
||||
t.Logf("flush 5 completed")
|
||||
t.Log("flush 5 completed")
|
||||
|
||||
stats, err = store.GetWorkspaceAgentStats(ctx, t5)
|
||||
require.NoError(t, err, "should not error getting stats")
|
||||
|
Reference in New Issue
Block a user