@@ -10,38 +10,53 @@ import (
1010
1111func TestTransformSpecialToolsets (t * testing.T ) {
1212 tests := []struct {
13- name string
14- input []string
15- expected []string
13+ name string
14+ input []string
15+ dynamicToolsets bool
16+ expected []string
1617 }{
1718 {
18- name : "empty slice" ,
19- input : []string {},
20- expected : []string {},
19+ name : "empty slice" ,
20+ input : []string {},
21+ dynamicToolsets : false ,
22+ expected : []string {},
2123 },
2224 {
23- name : "all only" ,
24- input : []string {"all" },
25- expected : []string {"all" },
25+ name : "nil input slice" ,
26+ input : nil ,
27+ dynamicToolsets : false ,
28+ expected : []string {},
2629 },
30+ // all test cases
2731 {
28- name : "all with other toolsets" ,
29- input : []string {"all" , "actions" , "gists" },
30- expected : []string {"all" },
32+ name : "all only" ,
33+ input : []string {"all" },
34+ dynamicToolsets : false ,
35+ expected : []string {"all" },
3136 },
3237 {
33- name : "all at the end" ,
34- input : []string {"actions" , "gists" , "all" },
35- expected : []string {"all" },
38+ name : "all appears multiple times" ,
39+ input : []string {"all" , "actions" , "all" },
40+ dynamicToolsets : false ,
41+ expected : []string {"all" },
3642 },
3743 {
38- name : "all with default" ,
39- input : []string {"default" , "all" , "actions" },
40- expected : []string {"all" },
44+ name : "all with other toolsets" ,
45+ input : []string {"all" , "actions" , "gists" },
46+ dynamicToolsets : false ,
47+ expected : []string {"all" },
4148 },
4249 {
43- name : "default only" ,
44- input : []string {"default" },
50+ name : "all with default" ,
51+ input : []string {"default" , "all" , "actions" },
52+ dynamicToolsets : false ,
53+ expected : []string {"all" },
54+ },
55+ // default test cases
56+ {
57+ name : "default only" ,
58+ input : []string {"default" },
59+ dynamicToolsets : false ,
4560 expected : []string {
4661 "context" ,
4762 "repos" ,
@@ -51,8 +66,9 @@ func TestTransformSpecialToolsets(t *testing.T) {
5166 },
5267 },
5368 {
54- name : "default with additional toolsets" ,
55- input : []string {"default" , "actions" , "gists" },
69+ name : "default with additional toolsets" ,
70+ input : []string {"default" , "actions" , "gists" },
71+ dynamicToolsets : false ,
5672 expected : []string {
5773 "actions" ,
5874 "gists" ,
@@ -64,44 +80,80 @@ func TestTransformSpecialToolsets(t *testing.T) {
6480 },
6581 },
6682 {
67- name : "default with overlapping toolsets" ,
68- input : []string {"default" , "issues" , "actions" },
83+ name : "no default present" ,
84+ input : []string {"actions" , "gists" , "notifications" },
85+ dynamicToolsets : false ,
86+ expected : []string {"actions" , "gists" , "notifications" },
87+ },
88+ {
89+ name : "duplicate toolsets without default" ,
90+ input : []string {"actions" , "gists" , "actions" },
91+ dynamicToolsets : false ,
92+ expected : []string {"actions" , "gists" },
93+ },
94+ {
95+ name : "duplicate toolsets with default" ,
96+ input : []string {"context" , "repos" , "issues" , "pull_requests" , "users" , "default" },
97+ dynamicToolsets : false ,
6998 expected : []string {
99+ "context" ,
100+ "repos" ,
70101 "issues" ,
102+ "pull_requests" ,
103+ "users" ,
104+ },
105+ },
106+ {
107+ name : "default appears multiple times with different toolsets in between" ,
108+ input : []string {"default" , "actions" , "default" , "gists" , "default" },
109+ dynamicToolsets : false ,
110+ expected : []string {
71111 "actions" ,
112+ "gists" ,
72113 "context" ,
73114 "repos" ,
115+ "issues" ,
74116 "pull_requests" ,
75117 "users" ,
76118 },
77119 },
120+ // Dynamic toolsets test cases
78121 {
79- name : "no default present" ,
80- input : []string {"actions" , "gists" , "notifications" },
81- expected : []string {"actions" , "gists" , "notifications" },
122+ name : "dynamic toolsets - all only should be filtered" ,
123+ input : []string {"all" },
124+ dynamicToolsets : true ,
125+ expected : []string {},
82126 },
83127 {
84- name : "duplicate toolsets without default" ,
85- input : []string {"actions" , "gists" , "actions" },
86- expected : []string {"actions" , "gists" },
128+ name : "dynamic toolsets - all with other toolsets" ,
129+ input : []string {"all" , "actions" , "gists" },
130+ dynamicToolsets : true ,
131+ expected : []string {"actions" , "gists" },
87132 },
88133 {
89- name : "duplicate toolsets with default" ,
90- input : []string {"actions" , "default" , "actions" , "issues" },
134+ name : "dynamic toolsets - all with default" ,
135+ input : []string {"all" , "default" , "actions" },
136+ dynamicToolsets : true ,
91137 expected : []string {
92138 "actions" ,
93- "issues" ,
94139 "context" ,
95140 "repos" ,
141+ "issues" ,
96142 "pull_requests" ,
97143 "users" ,
98144 },
99145 },
100146 {
101- name : "multiple defaults (edge case)" ,
102- input : []string {"default" , "actions" , "default" },
147+ name : "dynamic toolsets - no all present" ,
148+ input : []string {"actions" , "gists" },
149+ dynamicToolsets : true ,
150+ expected : []string {"actions" , "gists" },
151+ },
152+ {
153+ name : "dynamic toolsets - default only" ,
154+ input : []string {"default" },
155+ dynamicToolsets : true ,
103156 expected : []string {
104- "actions" ,
105157 "context" ,
106158 "repos" ,
107159 "issues" ,
@@ -110,8 +162,9 @@ func TestTransformSpecialToolsets(t *testing.T) {
110162 },
111163 },
112164 {
113- name : "all default toolsets already present with default" ,
114- input : []string {"context" , "repos" , "issues" , "pull_requests" , "users" , "default" },
165+ name : "only special keywords with dynamic mode" ,
166+ input : []string {"all" , "default" },
167+ dynamicToolsets : true ,
115168 expected : []string {
116169 "context" ,
117170 "repos" ,
@@ -120,11 +173,23 @@ func TestTransformSpecialToolsets(t *testing.T) {
120173 "users" ,
121174 },
122175 },
176+ {
177+ name : "all with default and overlapping default toolsets in dynamic mode" ,
178+ input : []string {"all" , "default" , "issues" , "repos" },
179+ dynamicToolsets : true ,
180+ expected : []string {
181+ "issues" ,
182+ "repos" ,
183+ "context" ,
184+ "pull_requests" ,
185+ "users" ,
186+ },
187+ },
123188 }
124189
125190 for _ , tt := range tests {
126191 t .Run (tt .name , func (t * testing.T ) {
127- result := transformSpecialToolsets (tt .input )
192+ result := cleanToolsets (tt .input , tt . dynamicToolsets )
128193
129194 // Check that the result has the correct length
130195 require .Len (t , result , len (tt .expected ), "result length should match expected length" )
@@ -155,7 +220,7 @@ func TestTransformSpecialToolsets(t *testing.T) {
155220func TestTransformSpecialToolsetsWithActualDefaults (t * testing.T ) {
156221 // This test verifies that the function uses the actual default toolsets from GetDefaultToolsetIDs()
157222 input := []string {"default" }
158- result := transformSpecialToolsets (input )
223+ result := cleanToolsets (input , false )
159224
160225 defaultToolsets := github .GetDefaultToolsetIDs ()
161226
0 commit comments