Skip to content

Commit ee2edef

Browse files
committed
test(sdk/go): add WithAnnotations and combined options tests
Add real-client gRPC tests for WithAnnotations alone and WithLabels+WithAnnotations combined to close the test gap where annotations were only exercised via the fake client. Signed-off-by: Roland Huß <rhuss@redhat.com>
1 parent 6ee183e commit ee2edef

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

sdk/go/openshell/v1/sandbox_client_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,43 @@ func TestSandboxCreate(t *testing.T) {
267267
assert.Equal(t, SandboxProvisioning, result.Status.Phase)
268268
}
269269

270+
func TestSandboxCreate_WithAnnotations(t *testing.T) {
271+
mock := newMockSandboxServer()
272+
client, cleanup := setupSandboxTest(t, mock)
273+
defer cleanup()
274+
275+
annotations := map[string]string{"purpose": "ci-test"}
276+
result, err := client.Create(context.Background(), "default", "ann-sandbox", &SandboxSpec{}, WithAnnotations(annotations))
277+
278+
require.NoError(t, err)
279+
require.NotNil(t, result)
280+
281+
mock.mu.Lock()
282+
defer mock.mu.Unlock()
283+
require.NotNil(t, mock.createRequest)
284+
assert.Equal(t, map[string]string{"purpose": "ci-test"}, mock.createRequest.Annotations)
285+
}
286+
287+
func TestSandboxCreate_WithLabelsAndAnnotations(t *testing.T) {
288+
mock := newMockSandboxServer()
289+
client, cleanup := setupSandboxTest(t, mock)
290+
defer cleanup()
291+
292+
labels := map[string]string{"env": "staging"}
293+
annotations := map[string]string{"owner": "team-a"}
294+
result, err := client.Create(context.Background(), "default", "both-sandbox", &SandboxSpec{},
295+
WithLabels(labels), WithAnnotations(annotations))
296+
297+
require.NoError(t, err)
298+
require.NotNil(t, result)
299+
300+
mock.mu.Lock()
301+
defer mock.mu.Unlock()
302+
require.NotNil(t, mock.createRequest)
303+
assert.Equal(t, map[string]string{"env": "staging"}, mock.createRequest.Labels)
304+
assert.Equal(t, map[string]string{"owner": "team-a"}, mock.createRequest.Annotations)
305+
}
306+
270307
func TestSandboxCreate_DefaultGPURequest(t *testing.T) {
271308
mock := newMockSandboxServer()
272309
client, cleanup := setupSandboxTest(t, mock)

0 commit comments

Comments
 (0)