Skip to content

Commit

Permalink
Remove error for missing testing aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Oct 24, 2023
1 parent 5e48742 commit 7aef0fe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
7 changes: 2 additions & 5 deletions internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,9 @@ func testCode(
contracts := make(map[string]common.Address, 0)
for _, contract := range *state.Contracts() {
alias := contract.Aliases.ByNetwork("testing")
if alias == nil {
return nil, fmt.Errorf(
"unable to find 'testing' alias for contract: %s", contract.Name,
)
if alias != nil {
contracts[contract.Name] = common.Address(alias.Address)
}
contracts[contract.Name] = common.Address(alias.Address)
}

testResults := make(map[string]cdcTests.Results, 0)
Expand Down
32 changes: 31 additions & 1 deletion internal/test/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,40 @@ func TestExecutingTests(t *testing.T) {
assert.ErrorContains(
t,
err,
"unable to find 'testing' alias for contract: Hello",
"could not find the address of contract: Hello",
)
})

t.Run("without testing alias for common contracts", func(t *testing.T) {
t.Parallel()

// Setup
_, state, _ := util.TestMocks(t)

c := config.Contract{
Name: tests.ContractHelloString.Name,
Location: tests.ContractHelloString.Filename,
Aliases: aliases,
}
state.Contracts().AddOrUpdate(c)
// fungibleToken has no `testing` alias, but it is not
// actually deployed/used, so there is no errror.
fungibleToken := config.Contract{
Name: "FungibleToken",
Location: "cadence/contracts/FungibleToken.cdc",
}
state.Contracts().AddOrUpdate(fungibleToken)

// Execute script
script := tests.TestScriptWithImport
testFiles := map[string][]byte{
script.Filename: script.Source,
}
_, err := testCode(testFiles, state, flagsTests{})

assert.NoError(t, err)
})

t.Run("with file read", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 7aef0fe

Please sign in to comment.