-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Philip-21 <[email protected]>
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
internal/blockchain/ethereum/connector/ethconnect/config_test.go
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,19 @@ | ||
package ethconnect | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestWriteConfig(t *testing.T) { | ||
dir := "testdata" | ||
configFilename := dir + filepath.Join("config.yaml") | ||
extraEvmConfigPath := dir + filepath.Join("/conflate/extra.yaml") | ||
p := Config{} | ||
t.Run("TestWriteConfig", func(t *testing.T) { | ||
err := p.WriteConfig(configFilename, extraEvmConfigPath) | ||
if err != nil { | ||
t.Logf("unable to write to config files: %v", err) | ||
} | ||
}) | ||
} |
97 changes: 97 additions & 0 deletions
97
internal/blockchain/ethereum/connector/ethconnect/docker_test.go
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,97 @@ | ||
package ethconnect | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hyperledger/firefly-cli/pkg/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type MockManfest struct { | ||
types.ManifestEntry | ||
GetDockerImageStringMck func() string | ||
} | ||
|
||
func TestGetServiceDefinition(t *testing.T) { | ||
getManifest := &MockManfest{ | ||
GetDockerImageStringMck: func() string { | ||
return "ethconnect_alpine:latest" | ||
}, | ||
} | ||
testServices := []struct { | ||
Name string | ||
Members *types.Stack | ||
DependentServices map[string]string | ||
ServiceName string | ||
}{ | ||
{ | ||
Name: "test_service_1", | ||
Members: &types.Stack{ | ||
Members: []*types.Organization{{ID: "firefly_1", ExposedConnectorPort: 3000}}, | ||
VersionManifest: &types.VersionManifest{Ethconnect: &getManifest.ManifestEntry}, | ||
}, | ||
DependentServices: map[string]string{ | ||
"service1": "running", | ||
"service2": "stopped", | ||
}, | ||
ServiceName: "ethconnect_firefly_1", | ||
}, | ||
{ | ||
Name: "test_service_2", | ||
Members: &types.Stack{ | ||
Members: []*types.Organization{{ID: "firefly_2", ExposedConnectorPort: 8002}}, | ||
VersionManifest: &types.VersionManifest{Ethconnect: &getManifest.ManifestEntry}, | ||
}, | ||
DependentServices: map[string]string{ | ||
"service1": "stopped", | ||
"service2": "running", | ||
}, | ||
ServiceName: "ethconnect_firefly_2", | ||
}, | ||
{ | ||
Name: "test_service_3", | ||
Members: &types.Stack{ | ||
Members: []*types.Organization{{ID: "firefly_3", ExposedConnectorPort: 8000}}, | ||
VersionManifest: &types.VersionManifest{Ethconnect: &getManifest.ManifestEntry}, | ||
}, | ||
DependentServices: map[string]string{ | ||
"service1": "stopped", | ||
"service2": "stopped", | ||
"service3": "running", | ||
}, | ||
ServiceName: "ethconnect_firefly_3", | ||
}, | ||
{ | ||
Name: "test_service_4", | ||
Members: &types.Stack{ | ||
Members: []*types.Organization{{ID: "firefly_4", ExposedConnectorPort: 7892}}, | ||
VersionManifest: &types.VersionManifest{Ethconnect: &getManifest.ManifestEntry}, | ||
}, | ||
DependentServices: map[string]string{ | ||
"service1": "stopped", | ||
"service2": "stopped", | ||
"service3": "stopped", | ||
"service4": "running", | ||
}, | ||
ServiceName: "ethconnect_firefly_4", | ||
}, | ||
} | ||
for _, tc := range testServices { | ||
t.Run(tc.Name, func(t *testing.T) { | ||
e := Ethconnect{} | ||
|
||
serviceDefinitions := e.GetServiceDefinitions(tc.Members, tc.DependentServices) | ||
assert.NotNil(t, serviceDefinitions) | ||
|
||
expectedCommand := "server -f ./config/config.yaml -d 2" | ||
if serviceDefinitions[0].Service.Command != expectedCommand { | ||
t.Errorf("Expected Command %q, got %q", expectedCommand, serviceDefinitions[0].Service.Command) | ||
} | ||
if serviceDefinitions[0].ServiceName != tc.ServiceName { | ||
t.Errorf("Expected ServiceName %q, got %q", tc.ServiceName, serviceDefinitions[0].ServiceName) | ||
} | ||
|
||
}) | ||
} | ||
|
||
} |
Empty file.
1 change: 1 addition & 0 deletions
1
internal/blockchain/ethereum/connector/ethconnect/testdataconfig.yaml
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 @@ | ||
{} |