Skip to content

Commit

Permalink
Fixed a few tests that where using viper.Set("chaincode.externalBuild…
Browse files Browse the repository at this point in the history
…ers", VARIABLE) instead of stringified data

Signed-off-by: Vladyslav Kopaihorodskyi <vlad.kopaygorodsky@gmail.com>
  • Loading branch information
kopaygorodsky committed Jul 19, 2022
1 parent 379c4ea commit 4271229
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions core/peer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,7 @@ func TestGlobalConfig(t *testing.T) {
viper.Set("metrics.statsd.prefix", "testPrefix")

viper.Set("chaincode.pull", false)
viper.Set("chaincode.externalBuilders", &[]ExternalBuilder{
{
Path: "relative/plugin_dir",
Name: "relative",
},
{
Path: "/absolute/plugin_dir",
Name: "absolute",
},
})
viper.Set("chaincode.externalBuilders", "[{name: relative, path: relative/plugin_dir}, {name: absolute, path: /absolute/plugin_dir}]")

coreConfig, err := GlobalConfig()
assert.NoError(t, err)
Expand Down Expand Up @@ -405,24 +396,7 @@ func TestGlobalConfigDefault(t *testing.T) {
func TestPropagateEnvironment(t *testing.T) {
defer viper.Reset()
viper.Set("peer.address", "localhost:8080")
viper.Set("chaincode.externalBuilders", &[]ExternalBuilder{
{
Name: "testName",
Environment: []string{"KEY=VALUE"},
Path: "/testPath",
},
{
Name: "testName",
PropagateEnvironment: []string{"KEY=VALUE"},
Path: "/testPath",
},
{
Name: "testName",
Environment: []string{"KEY=VALUE"},
PropagateEnvironment: []string{"KEY=VALUE2"},
Path: "/testPath",
},
})
viper.Set("chaincode.externalBuilders", "[{name: testName, environmentWhitelist: [KEY=VALUE], path: /testPath}, {name: testName, propagateEnvironment: [KEY=VALUE], path: /testPath}, {name: testName, environmentWhitelist: [KEY=VALUE], propagateEnvironment: [KEY=VALUE2], path: /testPath}]")
coreConfig, err := GlobalConfig()
assert.NoError(t, err)

Expand Down Expand Up @@ -478,23 +452,15 @@ func TestExternalBuilderConfigAsEnvVar(t *testing.T) {
func TestMissingExternalBuilderPath(t *testing.T) {
defer viper.Reset()
viper.Set("peer.address", "localhost:8080")
viper.Set("chaincode.externalBuilders", &[]ExternalBuilder{
{
Name: "testName",
},
})
viper.Set("chaincode.externalBuilders", "[{name: testName}]")
_, err := GlobalConfig()
assert.EqualError(t, err, "invalid external builder configuration, path attribute missing in one or more builders")
}

func TestMissingExternalBuilderName(t *testing.T) {
defer viper.Reset()
viper.Set("peer.address", "localhost:8080")
viper.Set("chaincode.externalBuilders", &[]ExternalBuilder{
{
Path: "relative/plugin_dir",
},
})
viper.Set("chaincode.externalBuilders", "[{path: relative/plugin_dir}]")
_, err := GlobalConfig()
assert.EqualError(t, err, "external builder at path relative/plugin_dir has no name attribute")
}

0 comments on commit 4271229

Please sign in to comment.