@@ -10,16 +10,18 @@ import { stringify } from "yaml";
1010import {
1111 SdkTspConfigValidationRule ,
1212 TspConfigCommonAzServiceDirMatchPatternSubRule ,
13- TspConfigGoContainingModuleMatchPatternSubRule ,
13+ TspConfigGoDpContainingModuleMatchPatternSubRule ,
1414 TspConfigGoDpEmitterOutputDirMatchPatternSubRule ,
15+ TspConfigGoDpModuleMatchPatternSubRule ,
1516 TspConfigGoDpServiceDirMatchPatternSubRule ,
17+ TspConfigGoMgmtContainingModuleMatchPatternSubRule ,
1618 TspConfigGoMgmtEmitterOutputDirMatchPatternSubRule ,
1719 TspConfigGoMgmtGenerateFakesTrueSubRule ,
1820 TspConfigGoMgmtGenerateSamplesTrueSubRule ,
1921 TspConfigGoMgmtHeadAsBooleanTrueSubRule ,
2022 TspConfigGoMgmtInjectSpansTrueSubRule ,
23+ TspConfigGoMgmtModuleMatchPatternSubRule ,
2124 TspConfigGoMgmtServiceDirMatchPatternSubRule ,
22- TspConfigGoModuleMatchPatternSubRule ,
2325 TspConfigJavaAzEmitterOutputDirMatchPatternSubRule ,
2426 TspConfigJavaMgmtEmitterOutputDirMatchPatternSubRule ,
2527 TspConfigJavaMgmtNamespaceFormatSubRule ,
@@ -292,7 +294,7 @@ const goManagementModuleTestCases = createEmitterOptionTestCases(
292294 "module" ,
293295 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" ,
294296 "github.com/Azure/azure-sdk-for-java/sdk/compute/arm-compute" ,
295- [ new TspConfigGoModuleMatchPatternSubRule ( ) ] ,
297+ [ new TspConfigGoMgmtModuleMatchPatternSubRule ( ) ] ,
296298 false ,
297299) ;
298300
@@ -302,7 +304,7 @@ const goManagementContainingModuleTestCases = createEmitterOptionTestCases(
302304 "containing-module" ,
303305 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" ,
304306 "github.com/Azure/azure-sdk-for-java/sdk/compute/arm-compute" ,
305- [ new TspConfigGoContainingModuleMatchPatternSubRule ( ) ] ,
307+ [ new TspConfigGoMgmtContainingModuleMatchPatternSubRule ( ) ] ,
306308 false ,
307309) ;
308310
@@ -348,8 +350,7 @@ const goDpModuleTestCases = createEmitterOptionTestCases(
348350 "module" ,
349351 "github.com/Azure/azure-sdk-for-go/sdk/messaging/aaa" ,
350352 "github.com/Azure/azure-sdk-for-cpp/bbb" ,
351- [ new TspConfigGoModuleMatchPatternSubRule ( ) ] ,
352- false ,
353+ [ new TspConfigGoDpModuleMatchPatternSubRule ( ) ] ,
353354) ;
354355
355356const goDpContainingModuleTestCases = createEmitterOptionTestCases (
@@ -358,7 +359,7 @@ const goDpContainingModuleTestCases = createEmitterOptionTestCases(
358359 "containing-module" ,
359360 "github.com/Azure/azure-sdk-for-go/sdk/messaging/aaa" ,
360361 "github.com/Azure/azure-sdk-for-cpp/bbb" ,
361- [ new TspConfigGoContainingModuleMatchPatternSubRule ( ) ] ,
362+ [ new TspConfigGoDpContainingModuleMatchPatternSubRule ( ) ] ,
362363 false ,
363364) ;
364365
@@ -645,10 +646,52 @@ parameters:
645646 subRules : [
646647 new TspConfigJavaMgmtNamespaceFormatSubRule ( ) ,
647648 new TspConfigTsRlcDpPackageNameMatchPatternSubRule ( ) ,
649+ new TspConfigGoDpEmitterOutputDirMatchPatternSubRule ( ) ,
650+ new TspConfigGoDpModuleMatchPatternSubRule ( ) ,
651+ new TspConfigGoDpContainingModuleMatchPatternSubRule ( ) ,
648652 ] ,
649653 } ,
650654] ;
651655
656+ const optionalRulesWithEmitterConfigTestCases : Case [ ] = [
657+ {
658+ description :
659+ "Validate Go DP emitter-output-dir should fail when not defined (emitter configured with model)" ,
660+ folder : "" ,
661+ tspconfigContent : `
662+ options:
663+ "@azure-tools/typespec-go":
664+ model: "a"
665+ ` ,
666+ success : false ,
667+ subRules : [ new TspConfigGoDpEmitterOutputDirMatchPatternSubRule ( ) ] ,
668+ } ,
669+ {
670+ description :
671+ "Validate Go Mgmt Module should fail when not defined (emitter configured with model)" ,
672+ folder : managementTspconfigFolder ,
673+ tspconfigContent : `
674+ options:
675+ "@azure-tools/typespec-go":
676+ model: "a"
677+ ` ,
678+ success : false ,
679+ subRules : [ new TspConfigGoMgmtModuleMatchPatternSubRule ( ) ] ,
680+ } ,
681+ {
682+ description :
683+ "Validate Go Mgmt Containing Module should fail when not defined (emitter configured with model)" ,
684+ folder : managementTspconfigFolder ,
685+ tspconfigContent : `
686+ options:
687+ "@azure-tools/typespec-go":
688+ model: "a"
689+ ` ,
690+ success : false ,
691+ subRules : [ new TspConfigGoMgmtContainingModuleMatchPatternSubRule ( ) ] ,
692+ } ,
693+ ] ;
694+
652695const suppressEntireRuleTestCase : Case = {
653696 description : "Suppress entire rule" ,
654697 folder : managementTspconfigFolder ,
@@ -690,7 +733,7 @@ options:
690733 folder : managementTspconfigFolder ,
691734 subRules : [
692735 new TspConfigGoMgmtEmitterOutputDirMatchPatternSubRule ( ) ,
693- new TspConfigGoModuleMatchPatternSubRule ( ) ,
736+ new TspConfigGoDpModuleMatchPatternSubRule ( ) ,
694737 ] ,
695738 tspconfigContent : `
696739options:
@@ -737,10 +780,6 @@ describe("tspconfig", function () {
737780 ...goManagementGenerateFakesTestCases ,
738781 ...goManagementHeadAsBooleanTestCases ,
739782 ...goManagementInjectSpansTestCases ,
740- ...goDpModuleTestCases ,
741- ...goDpContainingModuleTestCases ,
742- ...goDpEmitterOutputDirTestCases ,
743- ...goDpServiceDirTestCases ,
744783 // java
745784 ...javaAzEmitterOutputDirTestCases ,
746785 ...javaMgmtEmitterOutputDirTestCases ,
@@ -760,6 +799,12 @@ describe("tspconfig", function () {
760799 const optionalTestCases = [
761800 // Test cases for optional rules when emitter is not configured
762801 ...optionalRulesWithoutEmitterConfigTestCases ,
802+ ...optionalRulesWithEmitterConfigTestCases ,
803+ // go data plane
804+ ...goDpEmitterOutputDirTestCases ,
805+ ...goDpServiceDirTestCases ,
806+ ...goDpModuleTestCases ,
807+ ...goDpContainingModuleTestCases ,
763808 ] ;
764809
765810 it . each ( [ ...requiredTestCases , ...optionalTestCases ] ) ( `$description` , async ( c : Case ) => {
0 commit comments