@@ -2,14 +2,16 @@ const test = require('node:test');
22const assert = require ( 'node:assert' ) ;
33const path = require ( 'path' ) ;
44const { analyzeGoFile } = require ( '../src/analyze/go' ) ;
5+ const { parseCustomFunctionSignature } = require ( '../src/analyze/utils/customFunctionParser' ) ;
56
67test . describe ( 'analyzeGoFile' , ( ) => {
78 const fixturesDir = path . join ( __dirname , 'fixtures' ) ;
89 const testFilePath = path . join ( fixturesDir , 'go' , 'main.go' ) ;
910
1011 test ( 'should correctly analyze Go file with multiple tracking providers' , async ( ) => {
1112 const customFunction = 'customTrackFunction(userId, EVENT_NAME, PROPERTIES)' ;
12- const events = await analyzeGoFile ( testFilePath , customFunction ) ;
13+ const customFunctionSignatures = [ parseCustomFunctionSignature ( customFunction ) ] ;
14+ const events = await analyzeGoFile ( testFilePath , customFunctionSignatures ) ;
1315
1416 // Sort events by eventName for consistent ordering
1517 events . sort ( ( a , b ) => a . eventName . localeCompare ( b . eventName ) ) ;
@@ -103,7 +105,8 @@ test.describe('analyzeGoFile', () => {
103105
104106 test ( 'should handle files without tracking events' , async ( ) => {
105107 const emptyTestFile = path . join ( fixturesDir , 'go' , 'empty.go' ) ;
106- const events = await analyzeGoFile ( emptyTestFile , 'customTrack' ) ;
108+ const customFunctionSignatures = [ parseCustomFunctionSignature ( 'customTrack' ) ] ;
109+ const events = await analyzeGoFile ( emptyTestFile , customFunctionSignatures ) ;
107110 assert . deepStrictEqual ( events , [ ] ) ;
108111 } ) ;
109112
@@ -117,7 +120,8 @@ test.describe('analyzeGoFile', () => {
117120
118121 test ( 'should handle nested property types correctly' , async ( ) => {
119122 const customFunction = 'customTrackFunction(userId, EVENT_NAME, PROPERTIES)' ;
120- const events = await analyzeGoFile ( testFilePath , customFunction ) ;
123+ const customFunctionSignatures = [ parseCustomFunctionSignature ( customFunction ) ] ;
124+ const events = await analyzeGoFile ( testFilePath , customFunctionSignatures ) ;
121125
122126 const customEvent = events . find ( e => e . eventName === 'custom_event' ) ;
123127 assert . ok ( customEvent ) ;
@@ -141,7 +145,8 @@ test.describe('analyzeGoFile', () => {
141145
142146 test ( 'should match expected tracking-schema.yaml output' , async ( ) => {
143147 const customFunction = 'customTrackFunction(userId, EVENT_NAME, PROPERTIES)' ;
144- const events = await analyzeGoFile ( testFilePath , customFunction ) ;
148+ const customFunctionSignatures = [ parseCustomFunctionSignature ( customFunction ) ] ;
149+ const events = await analyzeGoFile ( testFilePath , customFunctionSignatures ) ;
145150
146151 // Create a map of events by name for easier verification
147152 const eventMap = { } ;
@@ -252,7 +257,8 @@ test.describe('analyzeGoFile', () => {
252257 ] ;
253258
254259 for ( const { sig, event } of variants ) {
255- const events = await analyzeGoFile ( testFilePath , sig ) ;
260+ const customFunctionSignatures = [ parseCustomFunctionSignature ( sig ) ] ;
261+ const events = await analyzeGoFile ( testFilePath , customFunctionSignatures ) ;
256262 const found = events . find ( e => e . eventName === event && e . source === 'custom' ) ;
257263 assert . ok ( found , `Should detect ${ event } for signature ${ sig } ` ) ;
258264 }
0 commit comments