Simplify function and structure names for tests

This commit is contained in:
Mikołaj Pęczkowski 2021-11-07 00:43:40 +01:00
parent 07ed716279
commit 38cd52ffd6
2 changed files with 9 additions and 9 deletions

View File

@ -13,7 +13,7 @@ import (
"gitlab.com/revalus/grm/config"
)
type TestDir struct {
type TestSetup struct {
rootFS billy.Filesystem
baseRepository struct {
fileSystem billy.Filesystem
@ -42,7 +42,7 @@ func createTmpDir() string {
return tempDir
}
func getTestDirForTests() TestDir {
func getTestSetup() TestSetup {
tmpDir := createTmpDir()
@ -71,7 +71,7 @@ func getTestDirForTests() TestDir {
checkErrorDuringPreparation(err)
return TestDir{
return TestSetup{
baseRepository: struct {
fileSystem billy.Filesystem
repo *git.Repository
@ -100,8 +100,8 @@ func getFSForLocalRepo(dirName string, baseFileSystem billy.Filesystem) (billy.F
return fsForLocalRepo, storageForTestRepo
}
func getBaseForTestingSyncCommand() (StatusChecker, *git.Repository, config.RepositoryConfig, TestDir) {
tmpDirWithInitialRepository := getTestDirForTests()
func getBaseForTestingSyncCommand() (StatusChecker, *git.Repository, config.RepositoryConfig, TestSetup) {
tmpDirWithInitialRepository := getTestSetup()
dirNameForLocalRepository := "testRepo"
fsForLocalRepo, storageForTestRepo := getFSForLocalRepo(dirNameForLocalRepository, tmpDirWithInitialRepository.rootFS)

View File

@ -12,7 +12,7 @@ import (
)
func TestIfBranchesAreEqual(t *testing.T) {
tmpDirWithInitialRepository := getTestDirForTests()
tmpDirWithInitialRepository := getTestSetup()
fakeLocalRepo, err := git.Clone(memory.NewStorage(), memfs.New(), &git.CloneOptions{
URL: tmpDirWithInitialRepository.baseRepository.fileSystem.Root(),
@ -42,7 +42,7 @@ func TestIfBranchesAreEqual(t *testing.T) {
func TestIfCurrentBranchIsDifferent(t *testing.T) {
tmpDirWithInitialRepository := getTestDirForTests()
tmpDirWithInitialRepository := getTestSetup()
fakeLocalRepo, err := git.Clone(memory.NewStorage(), memfs.New(), &git.CloneOptions{
URL: tmpDirWithInitialRepository.baseRepository.fileSystem.Root(),
})
@ -91,7 +91,7 @@ func TestIfCurrentBranchIsDifferent(t *testing.T) {
func TestCommandRepositoryDoesNotExists(t *testing.T) {
tmpDirWithInitialRepository := getTestDirForTests()
tmpDirWithInitialRepository := getTestSetup()
fsForLocalRepo, storageForTestRepo := getFSForLocalRepo("noMatterValue", tmpDirWithInitialRepository.rootFS)
_, err := git.Clone(storageForTestRepo, fsForLocalRepo, &git.CloneOptions{
@ -127,7 +127,7 @@ func TestCommandRepositoryDoesNotExists(t *testing.T) {
func TestCommandRepositoryNoRemoteBranch(t *testing.T) {
tmpDirWithInitialRepository := getTestDirForTests()
tmpDirWithInitialRepository := getTestSetup()
dirNameForLocalRepository := "testRepo"
fsForLocalRepo, storageForTestRepo := getFSForLocalRepo(dirNameForLocalRepository, tmpDirWithInitialRepository.rootFS)