Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New task for code migration #376

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

New task for code migration #376

wants to merge 3 commits into from

Conversation

ruiAzevedo19
Copy link
Collaborator

No description provided.

@ruiAzevedo19 ruiAzevedo19 added the enhancement New feature or request label Dec 20, 2024
@ruiAzevedo19 ruiAzevedo19 added this to the v0.7.0 milestone Dec 20, 2024
@ruiAzevedo19 ruiAzevedo19 self-assigned this Dec 20, 2024
evaluate/task/write-test.go Outdated Show resolved Hide resolved
evaluate/task/symflower.go Outdated Show resolved Hide resolved
evaluate/task/symflower.go Outdated Show resolved Hide resolved
evaluate/task/symflower.go Outdated Show resolved Hide resolved
testdata/java/migrate/repository.json Outdated Show resolved Hide resolved
Comment on lines +105 to +117
// MockModelCapabilityMigrate holds a mock implementing the "Model" and the "CapabilityMigrate" interface.
type MockModelCapabilityMigrate struct {
*MockModel
*MockCapabilityMigrate
}

// NewMockCapabilityMigrateNamed returns a new named mocked model.
func NewMockCapabilityMigrateNamed(t *testing.T, id string) *MockModelCapabilityMigrate {
return &MockModelCapabilityMigrate{
MockModel: NewMockModelNamed(t, id),
MockCapabilityMigrate: NewMockCapabilityMigrate(t),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to explicitly define this. If you ever need a "combined" interface, i.e. for tests, you can just create it on the fly. I did the same thing for some provider tests.

Comment on lines +133 to +134
fileName := filepath.Base(filePath)
fileName = strings.TrimSuffix(fileName, language.DefaultFileExtension())
if fileName == testFileName {
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to remove the implementation files? We don't need to remove those, right? Cause if the test file only executes code from one implementation file, we can keep the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With both implementation files I was getting 50% coverage, after removing one of them I got 100% coverage

Comment on lines +184 to +193
// Check if for each implementation file a test file exists.
for implementationFileName := range implementationFileNames {
if !testFileNames[implementationFileName] {
return pkgerrors.Errorf("the repository %q must contain a test file for each implementation file but found none for %q", repositoryPath, implementationFileName)
}
}

// Check if for each test file an implementation file exists.
for testFileName := range testFileNames {
if !implementationFileNames[testFileName] {
return pkgerrors.Errorf("the repository %q must contain an implementation file for each test file but found none for %q", repositoryPath, testFileName)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would maybe track them in two slices and then sort them and use slices.Equal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a cleaner solution indeed. The only thing is with this one we can know if there is a missing test file for a certain implementation file and vice-versa each leads to better logging I think. Using slices.Equal we only now that there is something missing, either a test file or a implementation file.

If you feel like that does not matter, I change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still change cause it leaves less room for errors and is easier to read. Let's go clean code > usability here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants