(t *testing.T)
| 643 | } |
| 644 | |
| 645 | func TestUpdateStartup(t *testing.T) { |
| 646 | t.Parallel() |
| 647 | |
| 648 | var ( |
| 649 | workspaceID = uuid.New() |
| 650 | agent = database.WorkspaceAgent{ |
| 651 | ID: uuid.New(), |
| 652 | } |
| 653 | ) |
| 654 | |
| 655 | t.Run("OK", func(t *testing.T) { |
| 656 | t.Parallel() |
| 657 | |
| 658 | dbM := dbmock.NewMockStore(gomock.NewController(t)) |
| 659 | |
| 660 | api := &agentapi.LifecycleAPI{ |
| 661 | AgentFn: func(ctx context.Context) (database.WorkspaceAgent, error) { |
| 662 | return agent, nil |
| 663 | }, |
| 664 | WorkspaceID: workspaceID, |
| 665 | Database: dbM, |
| 666 | Log: testutil.Logger(t), |
| 667 | // Not used by UpdateStartup. |
| 668 | PublishWorkspaceUpdateFn: nil, |
| 669 | } |
| 670 | |
| 671 | startup := &agentproto.Startup{ |
| 672 | Version: "v1.2.3", |
| 673 | ExpandedDirectory: "/path/to/expanded/dir", |
| 674 | Subsystems: []agentproto.Startup_Subsystem{ |
| 675 | agentproto.Startup_ENVBOX, |
| 676 | agentproto.Startup_ENVBUILDER, |
| 677 | agentproto.Startup_EXECTRACE, |
| 678 | }, |
| 679 | } |
| 680 | |
| 681 | dbM.EXPECT().UpdateWorkspaceAgentStartupByID(gomock.Any(), database.UpdateWorkspaceAgentStartupByIDParams{ |
| 682 | ID: agent.ID, |
| 683 | Version: startup.Version, |
| 684 | ExpandedDirectory: startup.ExpandedDirectory, |
| 685 | Subsystems: []database.WorkspaceAgentSubsystem{ |
| 686 | database.WorkspaceAgentSubsystemEnvbox, |
| 687 | database.WorkspaceAgentSubsystemEnvbuilder, |
| 688 | database.WorkspaceAgentSubsystemExectrace, |
| 689 | }, |
| 690 | APIVersion: "2.0", |
| 691 | }).Return(nil) |
| 692 | |
| 693 | ctx := agentapi.WithAPIVersion(context.Background(), "2.0") |
| 694 | resp, err := api.UpdateStartup(ctx, &agentproto.UpdateStartupRequest{ |
| 695 | Startup: startup, |
| 696 | }) |
| 697 | require.NoError(t, err) |
| 698 | require.Equal(t, startup, resp) |
| 699 | }) |
| 700 | |
| 701 | t.Run("BadVersion", func(t *testing.T) { |
| 702 | t.Parallel() |
nothing calls this directly
no test coverage detected