4
4
5
5
use Orchestra \Testbench \TestCase ;
6
6
use LucianoTonet \GroqLaravel \GroqServiceProvider ;
7
+ use LucianoTonet \GroqLaravel \Facades \Groq ;
8
+ use LucianoTonet \GroqPHP \Groq as GroqPHP ;
7
9
8
10
class ConfigTest extends TestCase
9
11
{
@@ -34,4 +36,54 @@ public function testConfigValues()
34
36
$ this ->assertNotNull (config ('groq.api_key ' ));
35
37
$ this ->assertEquals ('https://api.groq.com/openai/v1 ' , config ('groq.api_base ' ));
36
38
}
39
+
40
+ public function testSetOptions ()
41
+ {
42
+ // Setup
43
+ $ initialApiKey = config ('groq.api_key ' );
44
+
45
+ // Test setting new options
46
+ $ newOptions = [
47
+ 'apiKey ' => 'new_test_key ' ,
48
+ 'baseUrl ' => 'https://test-api.groq.com/v1 ' ,
49
+ 'timeout ' => 30000 ,
50
+ 'maxRetries ' => 3 ,
51
+ 'headers ' => ['X-Custom-Header ' => 'test ' ],
52
+ 'debug ' => true ,
53
+ 'stream ' => true ,
54
+ 'responseFormat ' => 'json '
55
+ ];
56
+
57
+ Groq::setOptions ($ newOptions );
58
+
59
+ // Verify API key was updated
60
+ $ this ->assertEquals ('new_test_key ' , Groq::apiKey ());
61
+ $ this ->assertEquals ('https://test-api.groq.com/v1 ' , Groq::baseUrl ());
62
+
63
+ // Verify that the instance maintains the new configuration
64
+ $ instance1 = app (GroqPHP::class);
65
+ $ this ->assertEquals ('new_test_key ' , $ instance1 ->apiKey ());
66
+
67
+ // Get a new instance and verify it has the same configuration
68
+ $ instance2 = app (GroqPHP::class);
69
+ $ this ->assertEquals ('new_test_key ' , $ instance2 ->apiKey ());
70
+ $ this ->assertSame ($ instance1 , $ instance2 ); // Should be the same instance
71
+ }
72
+
73
+ public function testSetOptionsPartial ()
74
+ {
75
+ // Setup
76
+ $ initialApiKey = config ('groq.api_key ' );
77
+
78
+ // Test setting only some options
79
+ $ newOptions = [
80
+ 'timeout ' => 20000 ,
81
+ 'debug ' => true
82
+ ];
83
+
84
+ Groq::setOptions ($ newOptions );
85
+
86
+ // Verify API key remained unchanged
87
+ $ this ->assertEquals ($ initialApiKey , Groq::apiKey ());
88
+ }
37
89
}
0 commit comments