@@ -156,23 +156,39 @@ func TestGenerate(t *testing.T) {
156156 }
157157}
158158
159- func TestGroupToModel_WithGroup (t * testing.T ) {
160- name , display := GroupToModel ("monitor.azure.com" , "fallback" )
161- if name != "monitor.azure.com" {
162- t .Fatalf ("expected model name 'monitor.azure.com', got '%s'" , name )
163- }
164- if display != "Monitor Azure Com" {
165- t .Fatalf ("expected display name 'Monitor Azure Com', got '%s'" , display )
166- }
167- }
168-
169- func TestGroupToModel_EmptyGroup (t * testing.T ) {
170- name , display := GroupToModel ("" , "fooBarBaz" )
171- if name != "fooBarBaz" {
172- t .Fatalf ("expected fallback model name 'fooBarBaz', got '%s'" , name )
159+ func TestGroupToModel (t * testing.T ) {
160+ cases := []struct {
161+ name string
162+ group string
163+ fallback string
164+ expectName string
165+ expectDisplay string
166+ }{
167+ {
168+ name : "with group" ,
169+ group : "monitor.azure.com" ,
170+ fallback : "ignored" ,
171+ expectName : "monitor.azure.com" ,
172+ expectDisplay : "Monitor Azure Com" ,
173+ },
174+ {
175+ name : "empty group uses fallback" ,
176+ group : "" ,
177+ fallback : "fooBarBaz" ,
178+ expectName : "fooBarBaz" ,
179+ expectDisplay : "Foo Bar Baz" ,
180+ },
173181 }
174- if display != "Foo Bar Baz" {
175- t .Fatalf ("expected display name 'Foo Bar Baz', got '%s'" , display )
182+ for _ , tc := range cases {
183+ t .Run (tc .name , func (t * testing.T ) {
184+ name , display := GroupToModel (tc .group , tc .fallback )
185+ if name != tc .expectName {
186+ t .Fatalf ("expected model name '%s', got '%s'" , tc .expectName , name )
187+ }
188+ if display != tc .expectDisplay {
189+ t .Fatalf ("expected display name '%s', got '%s'" , tc .expectDisplay , display )
190+ }
191+ })
176192 }
177193}
178194
0 commit comments