|
7 | 7 | "github.com/warpdotdev/oz-agent-worker/internal/types" |
8 | 8 | ) |
9 | 9 |
|
10 | | -func strPtr(v string) *string { return &v } |
11 | | -func intPtr(v int) *int { return &v } |
| 10 | +func strPtr(v string) *string { return &v } |
| 11 | +func intPtr(v int) *int { return &v } |
| 12 | +func accessPtr(v types.AccessLevel) *types.AccessLevel { return &v } |
12 | 13 |
|
13 | 14 | func TestAugmentArgsForTask_IdleOnCompletePrecedence(t *testing.T) { |
14 | 15 | baseArgs := []string{"agent", "run"} |
@@ -86,6 +87,60 @@ func TestAugmentArgsForTask_IdleOnCompletePrecedence(t *testing.T) { |
86 | 87 | opts: TaskAugmentOptions{}, |
87 | 88 | expected: []string{"agent", "run", "--model", "claude-sonnet-4", "--idle-on-complete", "12m"}, |
88 | 89 | }, |
| 90 | + { |
| 91 | + name: "adds --share public:view when session_sharing.public_access is VIEWER", |
| 92 | + task: &types.Task{ |
| 93 | + AgentConfigSnapshot: &types.AmbientAgentConfig{ |
| 94 | + SessionSharing: &types.SessionSharingConfig{ |
| 95 | + PublicAccess: accessPtr(types.AccessLevelViewer), |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + opts: TaskAugmentOptions{}, |
| 100 | + expected: []string{"agent", "run", "--share", "public:view", "--idle-on-complete"}, |
| 101 | + }, |
| 102 | + { |
| 103 | + name: "adds --share public:edit when session_sharing.public_access is EDITOR", |
| 104 | + task: &types.Task{ |
| 105 | + AgentConfigSnapshot: &types.AmbientAgentConfig{ |
| 106 | + SessionSharing: &types.SessionSharingConfig{ |
| 107 | + PublicAccess: accessPtr(types.AccessLevelEditor), |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | + opts: TaskAugmentOptions{}, |
| 112 | + expected: []string{"agent", "run", "--share", "public:edit", "--idle-on-complete"}, |
| 113 | + }, |
| 114 | + { |
| 115 | + name: "skips --share public when session_sharing is absent", |
| 116 | + task: &types.Task{ |
| 117 | + AgentConfigSnapshot: &types.AmbientAgentConfig{}, |
| 118 | + }, |
| 119 | + opts: TaskAugmentOptions{}, |
| 120 | + expected: []string{"agent", "run", "--idle-on-complete"}, |
| 121 | + }, |
| 122 | + { |
| 123 | + name: "skips --share public when public_access is nil", |
| 124 | + task: &types.Task{ |
| 125 | + AgentConfigSnapshot: &types.AmbientAgentConfig{ |
| 126 | + SessionSharing: &types.SessionSharingConfig{}, |
| 127 | + }, |
| 128 | + }, |
| 129 | + opts: TaskAugmentOptions{}, |
| 130 | + expected: []string{"agent", "run", "--idle-on-complete"}, |
| 131 | + }, |
| 132 | + { |
| 133 | + name: "silently omits --share public for unsupported access levels (defensive: FULL rejected earlier)", |
| 134 | + task: &types.Task{ |
| 135 | + AgentConfigSnapshot: &types.AmbientAgentConfig{ |
| 136 | + SessionSharing: &types.SessionSharingConfig{ |
| 137 | + PublicAccess: accessPtr(types.AccessLevel("FULL")), |
| 138 | + }, |
| 139 | + }, |
| 140 | + }, |
| 141 | + opts: TaskAugmentOptions{}, |
| 142 | + expected: []string{"agent", "run", "--idle-on-complete"}, |
| 143 | + }, |
89 | 144 | } |
90 | 145 |
|
91 | 146 | for _, tt := range tests { |
|
0 commit comments