Merge pull request #3844 from yixingjia/addTest

Add test case for Clair DB configuration
This commit is contained in:
yixingjia 2017-12-21 16:39:46 +08:00 committed by GitHub
commit 7c510fa2c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/vmware/harbor/src/common/utils/test" "github.com/vmware/harbor/src/common/utils/test"
"github.com/vmware/harbor/src/common"
) )
// test functions under package ui/config // test functions under package ui/config
@ -118,9 +119,17 @@ func TestConfig(t *testing.T) {
t.Fatalf("failed to get database: %v", err) t.Fatalf("failed to get database: %v", err)
} }
if _, err := ClairDB(); err != nil { clairDB, err := ClairDB();
if err != nil {
t.Fatalf("failed to get clair DB %v", err) t.Fatalf("failed to get clair DB %v", err)
} }
adminServerDefaultConfig := test.GetDefaultConfigMap()
assert.Equal(adminServerDefaultConfig[common.ClairDB],clairDB.Database)
assert.Equal(adminServerDefaultConfig[common.ClairDBUsername],clairDB.Username)
assert.Equal(adminServerDefaultConfig[common.ClairDBPassword],clairDB.Password)
assert.Equal(adminServerDefaultConfig[common.ClairDBHost], clairDB.Host)
assert.Equal(adminServerDefaultConfig[common.ClairDBPort], clairDB.Port)
if InternalNotaryEndpoint() != "http://notary-server:4443" { if InternalNotaryEndpoint() != "http://notary-server:4443" {
t.Errorf("Unexpected notary endpoint: %s", InternalNotaryEndpoint()) t.Errorf("Unexpected notary endpoint: %s", InternalNotaryEndpoint())
} }