@@ -921,6 +921,48 @@ func TestWorkspaceAgentAppHealth(t *testing.T) {
921921 require .EqualValues (t , codersdk .WorkspaceAppHealthUnhealthy , manifest .Apps [1 ].Health )
922922}
923923
924+ func TestWorkspaceAgentPostLogSource (t * testing.T ) {
925+ t .Parallel ()
926+
927+ t .Run ("OK" , func (t * testing.T ) {
928+ t .Parallel ()
929+ client , db := coderdtest .NewWithDatabase (t , nil )
930+ user := coderdtest .CreateFirstUser (t , client )
931+ ctx := testutil .Context (t , testutil .WaitShort )
932+
933+ r := dbfake .WorkspaceBuild (t , db , database.Workspace {
934+ OrganizationID : user .OrganizationID ,
935+ OwnerID : user .UserID ,
936+ }).WithAgent ().Do ()
937+
938+ agentClient := agentsdk .New (client .URL )
939+ agentClient .SetSessionToken (r .AgentToken )
940+
941+ req := agentsdk.PostLogSourceRequest {
942+ ID : uuid .New (),
943+ DisplayName : "colin logs" ,
944+ Icon : "/emojis/1f42e.png" ,
945+ }
946+
947+ res , err := agentClient .PostLogSource (ctx , req )
948+ require .NoError (t , err )
949+ assert .Equal (t , req .ID , res .ID )
950+ assert .Equal (t , req .DisplayName , res .DisplayName )
951+ assert .Equal (t , req .Icon , res .Icon )
952+ assert .NotZero (t , res .WorkspaceAgentID )
953+ assert .NotZero (t , res .CreatedAt )
954+
955+ // should be idempotent
956+ res , err = agentClient .PostLogSource (ctx , req )
957+ require .NoError (t , err )
958+ assert .Equal (t , req .ID , res .ID )
959+ assert .Equal (t , req .DisplayName , res .DisplayName )
960+ assert .Equal (t , req .Icon , res .Icon )
961+ assert .NotZero (t , res .WorkspaceAgentID )
962+ assert .NotZero (t , res .CreatedAt )
963+ })
964+ }
965+
924966// TestWorkspaceAgentReportStats tests the legacy (agent API v1) report stats endpoint.
925967func TestWorkspaceAgentReportStats (t * testing.T ) {
926968 t .Parallel ()
0 commit comments