Skip to content

Commit

Permalink
chore: Exclude methods from test function checks in architest (#3174)
Browse files Browse the repository at this point in the history
## Changes
- Exclude methods from architest that checks testing functions (test
functions cannot be methods)
- Fix spelling mistake
  • Loading branch information
sfc-gh-jcieslak authored Nov 7, 2024
1 parent 5aef117 commit edc46cc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ In addition to improved documentation, the tests showed us that we need to impro

**Description:** The issues with table columns ([\#420](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/420), [\#753](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/753), [\#2839](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2839)) are something we had in mind for a very long time and finally had a chance to work on a solution that would improve them, and possibly some of the other resources. In short, the use case for table columns consists of two use cases connected to each other:

- Ignoring the order of columns after creation. Users should be able to reorder, add, and remove columns from any place while still having somewhat control over column order on the Snowlake side.
- Ignoring the order of columns after creation. Users should be able to reorder, add, and remove columns from any place while still having somewhat control over column order on the Snowflake side.
- Updating a given column instead of removing and adding it again. Ignoring the order was an additional challenge because if someone wants to order the columns and change their name in one apply, then we need a way to identify this column to perform the correct action.

**Tests:** The tests were carried out on a resource created only for the purpose of the research ([resource reference](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/resources/object_renaming_lists_and_sets.go#L125)). Note that it won’t be normally visible and no other changes in other resources were made. We tested a few approaches regarding order ignoring and one on updating items.
Expand Down
1 change: 1 addition & 0 deletions pkg/architest/architest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func Test_Files(t *testing.T) {
expectedMethodNames []string
}{
{filePath: "testdata/dir1/sample1.go", expectedMethodNames: []string{}},
// object methods are skipped
{filePath: "testdata/dir1/sample2.go", expectedMethodNames: []string{"A"}},
}
for _, tt := range tests1 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/architest/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (f *File) ExportedMethods() Methods {
for _, d := range f.fileSrc.Decls {
if v, ok := d.(*ast.FuncDecl); ok {
name := v.Name.Name
if ast.IsExported(name) {
if ast.IsExported(name) && v.Recv == nil {
allExportedMethods = append(allExportedMethods, *NewMethod(name, f))
}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/architest/testdata/dir1/sample2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ package dir1
func A() {}

func a() {}

type obj struct{}

func (o obj) Exported() {}

func (o obj) private() {}

0 comments on commit edc46cc

Please sign in to comment.