-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(protoanalysis): fix wrong parser for proto package names (#3728)
* fix wrong parser for proto package names * add changelog * fix slice sort * rollback some changes * improve regex Co-authored-by: Jerónimo Albi <[email protected]> --------- Co-authored-by: Pantani <Pantani> Co-authored-by: Jerónimo Albi <[email protected]>
- Loading branch information
1 parent
679da53
commit c9c97e2
Showing
7 changed files
with
195 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package protoanalysis | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPackage_ModuleName(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
p Package | ||
want string | ||
}{ | ||
{ | ||
name: "test single name", | ||
p: Package{Name: "staking"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test two names", | ||
p: Package{Name: "cosmos.staking"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test three name", | ||
p: Package{Name: "cosmos.ignite.staking"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 1", | ||
p: Package{Name: "cosmos.staking.v1"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 2", | ||
p: Package{Name: "cosmos.staking.v2"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 10", | ||
p: Package{Name: "cosmos.staking.v10"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 1 beta 1", | ||
p: Package{Name: "cosmos.staking.v1beta1"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 1 beta 2", | ||
p: Package{Name: "cosmos.staking.v1beta2"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 2 beta 1", | ||
p: Package{Name: "cosmos.staking.v2beta1"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 2 beta 2", | ||
p: Package{Name: "cosmos.staking.v2beta2"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the version 3 alpha 5", | ||
p: Package{Name: "cosmos.staking.v3alpha5"}, | ||
want: "staking", | ||
}, | ||
{ | ||
name: "test with the wrong version", | ||
p: Package{Name: "cosmos.staking.v3bank5"}, | ||
want: "v3bank5", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := tt.p.ModuleName() | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters