Skip to content

Commit db5f45b

Browse files
authored
fix changelog function filter (Azure#20001)
* fix changelog function filter * add test * fix * rename to BeginDelete * add test...
1 parent ea7cedd commit db5f45b

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

eng/tools/generator/cmd/v2/common/changelogProcessor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func funcOperation(content *delta.Content) {
305305
if funcValue.Returns != nil {
306306
rs := strings.Split(*funcValue.Returns, ",")
307307
clientFuncResponse := rs[0]
308-
if strings.Contains(clientFunc[1], "runtime.Poller") {
308+
if strings.Contains(clientFuncResponse, "runtime") {
309309
re := regexp.MustCompile("\\[(?P<response>.*)\\]")
310310
clientFuncResponse = re.FindString(clientFuncResponse)
311311
clientFuncResponse = re.ReplaceAllString(clientFuncResponse, "${response}")
@@ -337,7 +337,7 @@ func LROFilter(changelog *model.Changelog) {
337337
clientFunc := strings.Split(bFunc, ".")
338338
if len(clientFunc) == 2 {
339339
if strings.Contains(clientFunc[1], "Begin") {
340-
clientFunc[1] = strings.ReplaceAll(clientFunc[1], "Being", "")
340+
clientFunc[1] = strings.TrimPrefix(clientFunc[1], "Begin")
341341
beginFunc = fmt.Sprintf("%s.%s", clientFunc[0], clientFunc[1])
342342
} else {
343343
beginFunc = fmt.Sprintf("%s.Begin%s", clientFunc[0], clientFunc[1])

eng/tools/generator/cmd/v2/common/changelogProcessor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestFuncFilter(t *testing.T) {
5353

5454
common.FilterChangelog(changelog, common.FuncFilter)
5555

56-
excepted := fmt.Sprint("### Breaking Changes\n\n- Function `*Client.Update` has been removed\n\n### Features Added\n\n- New function `*Client.BeginCreateOrUpdate(string, *ClientBeginCreateOrUpdateOptions) (ClientBeginCreateOrUpdateResponse, error)`\n")
56+
excepted := fmt.Sprint("### Breaking Changes\n\n- Function `*Client.BeingDelete` has been removed\n- Function `*Client.NewListPager` has been removed\n- Function `*Client.Update` has been removed\n\n### Features Added\n\n- New function `*Client.BeginCreateOrUpdate(string, *ClientBeginCreateOrUpdateOptions) (ClientBeginCreateOrUpdateResponse, error)`\n- New function `*Client.NewListBySubscriptionPager(*ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse]`\n")
5757
assert.Equal(t, excepted, changelog.ToCompactMarkdown())
5858
}
5959

@@ -75,7 +75,7 @@ func TestLROFilter(t *testing.T) {
7575

7676
common.FilterChangelog(changelog, common.FuncFilter, common.LROFilter)
7777

78-
excepted := fmt.Sprint("### Breaking Changes\n\n- Operation `*Client.CreateOrUpdate` has been changed to LRO, use `*Client.BeginCreateOrUpdate` instead.\n")
78+
excepted := fmt.Sprint("### Breaking Changes\n\n- Operation `*Client.BeginDelete` has been changed to non-LRO, use `*Client.Delete` instead.\n- Operation `*Client.CreateOrUpdate` has been changed to LRO, use `*Client.BeginCreateOrUpdate` instead.\n")
7979
assert.Equal(t, excepted, changelog.ToCompactMarkdown())
8080
}
8181

eng/tools/generator/cmd/v2/common/testdata/new/lro/lrofilter.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ func (client *Client) BeginCreateOrUpdate(resourceGroupName string, options *Cli
1313
type ClientBeginCreateOrUpdateOptions struct{}
1414

1515
type ClientBeginCreateOrUpdateResponse struct{}
16+
17+
func (client *Client) Delete(resourceGroupName string, options *ClientDeleteOptions) (ClientDeleteResponse, error) {
18+
19+
return ClientDeleteResponse{}, nil
20+
}
21+
22+
type ClientDeleteOptions struct{}
23+
24+
type ClientDeleteResponse struct{}

eng/tools/generator/cmd/v2/common/testdata/new/operation/funcfilter.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ func (client *Client) BeginCreateOrUpdate(resourceGroupName string, options *Cli
1313
type ClientBeginCreateOrUpdateOptions struct{}
1414

1515
type ClientBeginCreateOrUpdateResponse struct{}
16+
17+
func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] {
18+
return &runtime.Pager[ClientListBySubscriptionResponse]
19+
}
20+
21+
type ClientListBySubscriptionOptions struct{}
22+
23+
type ClientListBySubscriptionResponse struct{}

eng/tools/generator/cmd/v2/common/testdata/old/lro/lrofilter.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ func (client *Client) CreateOrUpdate(resourceGroupName string, options *ClientCr
1313
type ClientCreateOrUpdateOptions struct{}
1414

1515
type ClientCreateOrUpdateResponse struct{}
16+
17+
func (client *Client) BeginDelete(resourceGroupName string, options *ClientBeginDeleteOptions) (ClientBeginDeleteResponse, error) {
18+
19+
return ClientBeginDeleteResponse{}, nil
20+
}
21+
22+
type ClientBeginDeleteOptions struct{}
23+
24+
type ClientBeginDeleteResponse struct{}

eng/tools/generator/cmd/v2/common/testdata/old/operation/funcfilter.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,20 @@ func (client *Client) Update(resourceGroupName string, options *ClientUpdateOpti
1313
type ClientUpdateOptions struct{}
1414

1515
type ClientUpdateResponse struct{}
16+
17+
func (client *Client) BeingDelete(resourceGroupName string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientBeginDeleteResponse], error) {
18+
19+
return &runtime.Poller[ClientBeginDeleteResponse]{}, nil
20+
}
21+
22+
type ClientBeginDeleteOptions struct{}
23+
24+
type ClientBeginDeleteResponse struct{}
25+
26+
func (client *Client) NewListPager(resourceGroupName string, options *ClientListOptions) *runtime.Pager[ClientListResponse] {
27+
return &runtime.Pager[ClientListResponse]
28+
}
29+
30+
type ClientListOptions struct{}
31+
32+
type ClientListResponse struct{}

0 commit comments

Comments
 (0)