@@ -1049,7 +1049,7 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
1049
1049
require .EqualValues (t , 10 , manifest .Metadata [0 ].Interval )
1050
1050
require .EqualValues (t , 3 , manifest .Metadata [0 ].Timeout )
1051
1051
1052
- post := func (key string , mr codersdk.WorkspaceAgentMetadataResult ) {
1052
+ post := func (ctx context. Context , key string , mr codersdk.WorkspaceAgentMetadataResult ) {
1053
1053
err := agentClient .PostMetadata (ctx , agentsdk.PostMetadataRequest {
1054
1054
Metadata : []agentsdk.Metadata {
1055
1055
{
@@ -1073,8 +1073,11 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
1073
1073
Value : "bar" ,
1074
1074
}
1075
1075
1076
+ // Setup is complete, reset the context.
1077
+ ctx = testutil .Context (t , testutil .WaitMedium )
1078
+
1076
1079
// Initial post must come before the Watch is established.
1077
- post ("foo1" , wantMetadata1 )
1080
+ post (ctx , "foo1" , wantMetadata1 )
1078
1081
1079
1082
updates , errors := client .WatchWorkspaceAgentMetadata (ctx , agentID )
1080
1083
@@ -1116,14 +1119,14 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
1116
1119
require .Zero (t , update [1 ].Result .CollectedAt )
1117
1120
1118
1121
wantMetadata2 := wantMetadata1
1119
- post ("foo2" , wantMetadata2 )
1122
+ post (ctx , "foo2" , wantMetadata2 )
1120
1123
update = recvUpdate ()
1121
1124
require .Len (t , update , 3 )
1122
1125
check (wantMetadata1 , update [0 ], true )
1123
1126
check (wantMetadata2 , update [1 ], true )
1124
1127
1125
1128
wantMetadata1 .Error = "error"
1126
- post ("foo1" , wantMetadata1 )
1129
+ post (ctx , "foo1" , wantMetadata1 )
1127
1130
update = recvUpdate ()
1128
1131
require .Len (t , update , 3 )
1129
1132
check (wantMetadata1 , update [0 ], true )
@@ -1133,7 +1136,7 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
1133
1136
tooLongValueMetadata .Value = strings .Repeat ("a" , maxValueLen * 2 )
1134
1137
tooLongValueMetadata .Error = ""
1135
1138
tooLongValueMetadata .CollectedAt = time .Now ()
1136
- post ("foo3" , tooLongValueMetadata )
1139
+ post (ctx , "foo3" , tooLongValueMetadata )
1137
1140
got := recvUpdate ()[2 ]
1138
1141
for i := 0 ; i < 2 && len (got .Result .Value ) != maxValueLen ; i ++ {
1139
1142
got = recvUpdate ()[2 ]
@@ -1142,7 +1145,7 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
1142
1145
require .NotEmpty (t , got .Result .Error )
1143
1146
1144
1147
unknownKeyMetadata := wantMetadata1
1145
- post ("unknown" , unknownKeyMetadata )
1148
+ post (ctx , "unknown" , unknownKeyMetadata )
1146
1149
}
1147
1150
1148
1151
type testWAMErrorStore struct {
0 commit comments