Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ func testContractExistsInFile(testFilePath, contractName string) bool {
return false
}

return strings.Contains(string(content), "contract "+contractName)
contentStr := string(content)
return strings.Contains(contentStr, "contract "+contractName) ||
strings.Contains(contentStr, "interface "+contractName) ||
strings.Contains(contentStr, "library "+contractName)
}

// Test name validation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestTestContractExistsInFile(t *testing.T) {
defer cleanup()

_ = os.MkdirAll("test", 0755)
_ = os.WriteFile("test/Contract.t.sol", []byte("contract MyContract_Test {}\ncontract OtherContract {}"), 0644)
_ = os.WriteFile("test/Contract.t.sol", []byte("contract MyContract_Test {}\ninterface IHelper {}\nlibrary LibHelper {}"), 0644)

if testContractExistsInFile("", "MyContract_Test") {
t.Error("empty path should return false")
Expand All @@ -93,6 +93,12 @@ func TestTestContractExistsInFile(t *testing.T) {
if !testContractExistsInFile("test/Contract.t.sol", "MyContract_Test") {
t.Error("should find existing contract")
}
if !testContractExistsInFile("test/Contract.t.sol", "IHelper") {
t.Error("should find existing interface")
}
if !testContractExistsInFile("test/Contract.t.sol", "LibHelper") {
t.Error("should find existing library")
}
if testContractExistsInFile("test/Contract.t.sol", "NonExistent_Test") {
t.Error("should return false for non-existent contract")
}
Expand Down