Restructure project directories

Follow the standard of all go projects
This commit is contained in:
Mikołaj Pęczkowski 2024-01-13 15:39:40 +01:00
parent 741f18efd1
commit 5445ce1ccf
20 changed files with 39 additions and 42 deletions

View file

@ -1,64 +0,0 @@
package commands
import (
"fmt"
"os"
"testing"
"gitlab.com/revalus/grm/config"
)
func TestSyncInit(t *testing.T) {
sync := NewSynchronizer("test")
if sync.workspace != "test" {
t.Errorf("Expected to get \"test\", instead of this got %v", sync.workspace)
}
}
func TestSyncCommand(t *testing.T) {
testSetup := getTestSetup()
sync := Synchronizer{
workspace: testSetup.rootFS.Root(),
}
cfg := config.RepositoryConfig{
Src: fmt.Sprintf("file://%v", testSetup.baseRepository.fileSystem.Root()),
Dest: "awesome-go",
}
cloneStatus := sync.Command(cfg)
if cloneStatus.Error {
t.Errorf("Unexpected error: %v", cloneStatus.Message)
}
info, err := os.Stat(fmt.Sprintf("%v/awesome-go/.git", testSetup.rootFS.Root()))
if err != nil {
t.Errorf("Unexpected error: %v", err.Error())
}
if !info.IsDir() {
t.Errorf("Expected that the selected path is dir")
}
if cloneStatus.Changed != true {
t.Errorf("Expected that the status is changed")
}
if cloneStatus.Message != syncCloned {
t.Errorf("Expected to get %v, instead of this got %v", syncCloned, cloneStatus.Message)
}
fetchStatus := sync.Command(cfg)
if fetchStatus.Error {
t.Errorf("Unexpected error: %v", err.Error())
}
if fetchStatus.Changed != false {
t.Errorf("Expected that the status is not changed")
}
if fetchStatus.Message != syncUpToDate {
t.Errorf("Expected to get %v, instead of this got %v", syncUpToDate, cloneStatus.Message)
}
}