@@ -14,6 +14,7 @@ type HTTPSuiteRequest struct {
1414 Name string `json:"name"`
1515 Description string `json:"description"`
1616 EnvironmentName string `json:"environment_name"`
17+ NewSessionPerTest bool `json:"new_session_per_test,omitempty"` // Optional flag to create a new user session for each test (default: false)
1718 Tests []HTTPTestRequest `json:"tests"`
1819 ApiKey string `json:"api_key,omitempty"` // Optional token to override global.VoiceflowAPIKey
1920 VoiceflowSubdomain string `json:"voiceflow_subdomain,omitempty"` // Optional subdomain to override global.VoiceflowSubdomain
@@ -68,7 +69,7 @@ func ExecuteFromHTTPRequest(suiteReq HTTPSuiteRequest) *ExecuteSuiteResult {
6869// executeHTTPSuite executes a suite from HTTP request data
6970func executeHTTPSuite (suiteReq HTTPSuiteRequest , logCollector * LogCollector ) error {
7071 // Define the user ID
71- userID := uuid .New ().String ()
72+ userID := "test-" + uuid .New ().String ()
7273
7374 if suiteReq .VoiceflowSubdomain != "" {
7475 logCollector .AddLog ("Using Voiceflow subdomain: " + suiteReq .VoiceflowSubdomain )
@@ -77,11 +78,20 @@ func executeHTTPSuite(suiteReq HTTPSuiteRequest, logCollector *LogCollector) err
7778 logCollector .AddLog ("Suite: " + suiteReq .Name )
7879 logCollector .AddLog ("Description: " + suiteReq .Description )
7980 logCollector .AddLog ("Environment: " + suiteReq .EnvironmentName )
80- logCollector .AddLog ("User ID: " + userID )
81+ if suiteReq .NewSessionPerTest {
82+ logCollector .AddLog ("New session per test: enabled" )
83+ } else {
84+ logCollector .AddLog ("User ID: " + userID )
85+ }
8186 logCollector .AddLog ("Running Tests:" )
8287
8388 // Execute each test directly from the request data
8489 for _ , testReq := range suiteReq .Tests {
90+ // Create a new user ID for each test if newSessionPerTest is enabled
91+ if suiteReq .NewSessionPerTest {
92+ userID = "test-" + uuid .New ().String ()
93+ logCollector .AddLog ("User ID for test " + testReq .ID + ": " + userID )
94+ }
8595 logCollector .AddLog ("Running Test ID: " + testReq .ID )
8696 err := runTest (suiteReq .EnvironmentName , userID , testReq .Test , suiteReq .ApiKey , suiteReq .VoiceflowSubdomain , logCollector , suiteReq .OpenAIConfig )
8797 if err != nil {
@@ -97,7 +107,7 @@ func executeHTTPSuite(suiteReq HTTPSuiteRequest, logCollector *LogCollector) err
97107func ExecuteSuite (suitesPath string ) error {
98108
99109 // Define the user ID
100- userID := uuid .New ().String ()
110+ userID := "test-" + uuid .New ().String ()
101111
102112 // Load all suites from the path
103113 suites , err := utils .LoadSuitesFromPath (suitesPath )
@@ -108,10 +118,19 @@ func ExecuteSuite(suitesPath string) error {
108118
109119 // Iterate over each suite and its tests
110120 for _ , suite := range suites {
111- global .Log .Infof ("Suite: %s\n Description: %s\n Environment: %s\n User ID: %s" , suite .Name , suite .Description , suite .EnvironmentName , userID )
121+ if suite .NewSessionPerTest {
122+ global .Log .Infof ("Suite: %s\n Description: %s\n Environment: %s\n New session per test: enabled" , suite .Name , suite .Description , suite .EnvironmentName )
123+ } else {
124+ global .Log .Infof ("Suite: %s\n Description: %s\n Environment: %s\n User ID: %s" , suite .Name , suite .Description , suite .EnvironmentName , userID )
125+ }
112126 global .Log .Infof ("Running Tests:" )
113127
114128 for _ , testFile := range suite .Tests {
129+ // Create a new user ID for each test if newSessionPerTest is enabled
130+ if suite .NewSessionPerTest {
131+ userID = "test-" + uuid .New ().String ()
132+ global .Log .Infof ("User ID for test %s: %s" , testFile .ID , userID )
133+ }
115134 test , err := utils .LoadTestFromPath (testFile .File )
116135 if err != nil {
117136 global .Log .Errorf ("Error loading test: %v" , err )
0 commit comments