MCPcopy Index your code
hub / github.com/coder/coder / TestWorkspaceBuildLogs

Function TestWorkspaceBuildLogs

coderd/workspacebuilds_test.go:1043–1095  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1041}
1042
1043func TestWorkspaceBuildLogs(t *testing.T) {
1044 t.Parallel()
1045 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
1046 user := coderdtest.CreateFirstUser(t, client)
1047 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
1048 Parse: echo.ParseComplete,
1049 ProvisionGraph: []*proto.Response{{
1050 Type: &proto.Response_Log{
1051 Log: &proto.Log{
1052 Level: proto.LogLevel_INFO,
1053 Output: "example",
1054 },
1055 },
1056 }, {
1057 Type: &proto.Response_Graph{
1058 Graph: &proto.GraphComplete{
1059 Resources: []*proto.Resource{{
1060 Name: "some",
1061 Type: "example",
1062 Agents: []*proto.Agent{{
1063 Id: "something",
1064 Name: "dev",
1065 Auth: &proto.Agent_Token{},
1066 }},
1067 }, {
1068 Name: "another",
1069 Type: "example",
1070 }},
1071 },
1072 },
1073 }},
1074 })
1075 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
1076 template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
1077 workspace := coderdtest.CreateWorkspace(t, client, template.ID)
1078
1079 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
1080 defer cancel()
1081
1082 logs, closer, err := client.WorkspaceBuildLogsAfter(ctx, workspace.LatestBuild.ID, 0)
1083 require.NoError(t, err)
1084 defer closer.Close()
1085 for {
1086 log, ok := <-logs
1087 if !ok {
1088 break
1089 }
1090 if log.Output == "example" {
1091 return
1092 }
1093 }
1094 require.Fail(t, "example message never happened")
1095}
1096
1097func TestWorkspaceBuildLogsFormat(t *testing.T) {
1098 t.Parallel()

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92
CloseMethod · 0.65
FailMethod · 0.45

Tested by

no test coverage detected