From 428d429e179fd04ff053cd1e6bb607d6eaed702f Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Wed, 31 Aug 2016 02:38:06 -0700 Subject: [PATCH] add testing code, fix issue. --- dao/dao_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dao/dao_test.go b/dao/dao_test.go index 75b86c0..c28b47d 100644 --- a/dao/dao_test.go +++ b/dao/dao_test.go @@ -541,7 +541,10 @@ func TestGetAccessLogCreator(t *testing.T) { 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 { 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) } - 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 { 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, } - _, err := AddRepository(repoRecord) + err := AddRepository(repoRecord) if err != nil { t.Errorf("Error occurred in AddRepository: %v", err) } @@ -1595,7 +1601,6 @@ func TestGetRepositoryByName(t *testing.T) { } func TestIncreasePullCount(t *testing.T) { - var err error if err := IncreasePullCount(currentRepository.Name); err != nil { 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) { var exists bool - var err error - exists, err = RepositoryExists(currentRepository.Name) - if err != nil { - t.Errorf("Error occurred in RepositoryExists: %v", err) - } + exists = RepositoryExists(currentRepository.Name) if !exists { t.Errorf("The repository with name: %d, does not exist", currentRepository.Name) } } func TestDeleteRepository(t *testing.T) { - var err error err := DeleteRepository(currentRepository.Name) if err != nil { t.Errorf("Error occurred in DeleteRepository: %v", err)