mirror of
https://github.com/goharbor/harbor
synced 2025-05-18 22:31:08 +00:00
add testing code, fix issue.
This commit is contained in:
parent
b081909de7
commit
428d429e17
@ -541,7 +541,10 @@ func TestGetAccessLogCreator(t *testing.T) {
|
|||||||
t.Errorf("Error occurred in AccessLog: %v", err)
|
t.Errorf("Error occurred in AccessLog: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
user := GetAccessLogCreator(currentProject.Name + "/ubuntu")
|
user, err := GetAccessLogCreator(currentProject.Name + "/ubuntu")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error occurred in GetAccessLogCreator: %v", err)
|
||||||
|
}
|
||||||
if user != currentUser.Username {
|
if user != currentUser.Username {
|
||||||
t.Errorf("The access log creator does not match, expected: %s, actual: %s", currentUser.Username, user)
|
t.Errorf("The access log creator does not match, expected: %s, actual: %s", currentUser.Username, user)
|
||||||
}
|
}
|
||||||
@ -562,7 +565,10 @@ func TestCountPull(t *testing.T) {
|
|||||||
t.Errorf("Error occurred in AccessLog: %v", err)
|
t.Errorf("Error occurred in AccessLog: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pullCount := CountPull(currentProject.Name + "/ubuntu")
|
pullCount, err := CountPull(currentProject.Name + "/ubuntu")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error occurred in CountPull: %v", err)
|
||||||
|
}
|
||||||
if pullCount != 3 {
|
if pullCount != 3 {
|
||||||
t.Errorf("The access log pull count does not match, expected: 3, actual: %d", pullCount)
|
t.Errorf("The access log pull count does not match, expected: 3, actual: %d", pullCount)
|
||||||
}
|
}
|
||||||
@ -1564,7 +1570,7 @@ func TestAddRepository(t *testing.T) {
|
|||||||
StarCount: 0,
|
StarCount: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := AddRepository(repoRecord)
|
err := AddRepository(repoRecord)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error occurred in AddRepository: %v", err)
|
t.Errorf("Error occurred in AddRepository: %v", err)
|
||||||
}
|
}
|
||||||
@ -1595,7 +1601,6 @@ func TestGetRepositoryByName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIncreasePullCount(t *testing.T) {
|
func TestIncreasePullCount(t *testing.T) {
|
||||||
var err error
|
|
||||||
if err := IncreasePullCount(currentRepository.Name); err != nil {
|
if err := IncreasePullCount(currentRepository.Name); err != nil {
|
||||||
log.Errorf("Error happens when increasing pull count: %v", currentRepository.Name)
|
log.Errorf("Error happens when increasing pull count: %v", currentRepository.Name)
|
||||||
}
|
}
|
||||||
@ -1615,18 +1620,13 @@ func TestIncreasePullCount(t *testing.T) {
|
|||||||
|
|
||||||
func TestRepositoryExists(t *testing.T) {
|
func TestRepositoryExists(t *testing.T) {
|
||||||
var exists bool
|
var exists bool
|
||||||
var err error
|
exists = RepositoryExists(currentRepository.Name)
|
||||||
exists, err = RepositoryExists(currentRepository.Name)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Error occurred in RepositoryExists: %v", err)
|
|
||||||
}
|
|
||||||
if !exists {
|
if !exists {
|
||||||
t.Errorf("The repository with name: %d, does not exist", currentRepository.Name)
|
t.Errorf("The repository with name: %d, does not exist", currentRepository.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteRepository(t *testing.T) {
|
func TestDeleteRepository(t *testing.T) {
|
||||||
var err error
|
|
||||||
err := DeleteRepository(currentRepository.Name)
|
err := DeleteRepository(currentRepository.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error occurred in DeleteRepository: %v", err)
|
t.Errorf("Error occurred in DeleteRepository: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user