forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopilotClientModeTest.java
More file actions
63 lines (52 loc) · 2.21 KB
/
Copy pathCopilotClientModeTest.java
File metadata and controls
63 lines (52 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import com.github.copilot.rpc.CopilotClientMode;
import com.github.copilot.rpc.CopilotClientOptions;
/**
* Tests for {@link CopilotClientMode} and Empty mode validation.
*/
public class CopilotClientModeTest {
@Test
void testDefaultModeIsCopilotCli() {
var opts = new CopilotClientOptions();
assertEquals(CopilotClientMode.COPILOT_CLI, opts.getMode());
}
@Test
void testSetModeEmpty() {
var opts = new CopilotClientOptions();
opts.setMode(CopilotClientMode.EMPTY);
assertEquals(CopilotClientMode.EMPTY, opts.getMode());
}
@Test
void testEmptyModeRequiresCopilotHome() {
var opts = new CopilotClientOptions().setMode(CopilotClientMode.EMPTY).setAutoStart(false);
// Empty mode without copilotHome should throw
var ex = assertThrows(IllegalArgumentException.class, () -> new CopilotClient(opts));
assertTrue(ex.getMessage().contains("Empty mode"));
}
@Test
void testEmptyModeWithCopilotHome() {
var opts = new CopilotClientOptions().setMode(CopilotClientMode.EMPTY).setCopilotHome("/tmp/copilot-home")
.setAutoStart(false);
// Should not throw - copilotHome is set
var client = new CopilotClient(opts);
assertEquals(ConnectionState.DISCONNECTED, client.getState());
client.close();
}
@Test
void testCopilotClientModeEnumValues() {
assertEquals(2, CopilotClientMode.values().length);
assertEquals(CopilotClientMode.EMPTY, CopilotClientMode.valueOf("EMPTY"));
assertEquals(CopilotClientMode.COPILOT_CLI, CopilotClientMode.valueOf("COPILOT_CLI"));
}
@Test
void testEnumSerializationNames() {
// CopilotClientMode is a plain enum; verify the values exist
assertNotNull(CopilotClientMode.EMPTY);
assertNotNull(CopilotClientMode.COPILOT_CLI);
}
}