From e6ad19825f58e70be904cf3baad15ba8c1233d2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Aug 2025 01:11:56 +0000 Subject: [PATCH 1/2] chore: bump github.com/stretchr/testify from 1.10.0 to 1.11.1 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.10.0 to 1.11.1. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.10.0...v1.11.1) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-version: 1.11.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2aea7fb49bd13..1c303604e141e 100644 --- a/go.mod +++ b/go.mod @@ -175,7 +175,7 @@ require ( github.com/spf13/afero v1.14.0 github.com/spf13/pflag v1.0.6 github.com/sqlc-dev/pqtype v0.3.0 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 github.com/swaggo/http-swagger/v2 v2.0.1 github.com/swaggo/swag v1.16.2 github.com/tidwall/gjson v1.18.0 diff --git a/go.sum b/go.sum index ae851abe30694..16630b5175657 100644 --- a/go.sum +++ b/go.sum @@ -1765,8 +1765,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw= From 44d046205ecb56d37298fd7a09ccc0b000ce47de Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Tue, 2 Sep 2025 03:01:14 +0000 Subject: [PATCH 2/2] fix tests failing due to require.Eventually change --- coderd/metricscache/metricscache_test.go | 17 ++++++++--------- coderd/prometheusmetrics/aggregator_test.go | 16 ++++++++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/coderd/metricscache/metricscache_test.go b/coderd/metricscache/metricscache_test.go index 4582187a33651..a704c5dda2188 100644 --- a/coderd/metricscache/metricscache_test.go +++ b/coderd/metricscache/metricscache_test.go @@ -261,20 +261,19 @@ func TestCache_BuildTime(t *testing.T) { wantTransition := codersdk.WorkspaceTransition(tt.args.transition) require.Eventuallyf(t, func() bool { stats := cache.TemplateBuildTimeStats(template.ID) - return stats[wantTransition] != codersdk.TransitionStats{} + ts := stats[wantTransition] + return ts.P50 != nil && *ts.P50 == tt.want.buildTimeMs }, testutil.WaitLong, testutil.IntervalMedium, - "BuildTime never populated", + "P50 never reached expected value for %v", wantTransition, ) - gotStats = cache.TemplateBuildTimeStats(template.ID) - for transition, stats := range gotStats { + gotStats := cache.TemplateBuildTimeStats(template.ID) + for transition, ts := range gotStats { if transition == wantTransition { - require.Equal(t, tt.want.buildTimeMs, *stats.P50) - } else { - require.Empty( - t, stats, "%v", transition, - ) + // Checked above + continue } + require.Empty(t, ts, "%v", transition) } } else { var stats codersdk.TemplateBuildTimeStats diff --git a/coderd/prometheusmetrics/aggregator_test.go b/coderd/prometheusmetrics/aggregator_test.go index 6cbe5514b1c2e..f3441eccdd4db 100644 --- a/coderd/prometheusmetrics/aggregator_test.go +++ b/coderd/prometheusmetrics/aggregator_test.go @@ -194,15 +194,19 @@ func verifyCollectedMetrics(t *testing.T, expected []*agentproto.Stats_Metric, a var d dto.Metric err := actual[i].Write(&d) - require.NoError(t, err) + assert.NoError(t, err) switch e.Type { case agentproto.Stats_Metric_COUNTER: - require.Equal(t, e.Value, d.Counter.GetValue()) + if e.Value != d.Counter.GetValue() { + return false + } case agentproto.Stats_Metric_GAUGE: - require.Equal(t, e.Value, d.Gauge.GetValue()) + if e.Value != d.Gauge.GetValue() { + return false + } default: - require.Failf(t, "unsupported type: %s", string(e.Type)) + assert.Failf(t, "unsupported type: %s", string(e.Type)) } expectedLabels := make([]*agentproto.Stats_Metric_Label, len(e.Labels)) @@ -215,7 +219,7 @@ func verifyCollectedMetrics(t *testing.T, expected []*agentproto.Stats_Metric, a } sort.Slice(expectedLabels, sortFn) sort.Slice(dtoLabels, sortFn) - require.Equal(t, expectedLabels, dtoLabels, d.String()) + assert.Equal(t, expectedLabels, dtoLabels, d.String()) } return true } @@ -229,7 +233,7 @@ func prometheusMetricToString(t *testing.T, m prometheus.Metric) string { var d dto.Metric err := m.Write(&d) - require.NoError(t, err) + assert.NoError(t, err) dtoLabels := asMetricAgentLabels(d.GetLabel()) sort.Slice(dtoLabels, func(i, j int) bool { return dtoLabels[i].Name < dtoLabels[j].Name