Skip to content

Commit

Permalink
Moved to internal package structure (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
retr0h committed Nov 12, 2023
1 parent fc6623b commit 0bb3da1
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cmd/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"os"
"path/filepath"

"github.com/retr0h/go-gilt/repositories"
"github.com/retr0h/go-gilt/util"
"github.com/retr0h/go-gilt/internal/repositories"
"github.com/retr0h/go-gilt/internal/util"
"github.com/spf13/cobra"
)

Expand Down
5 changes: 3 additions & 2 deletions git/git.go → internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
"path/filepath"

"github.com/logrusorgru/aurora"
"github.com/retr0h/go-gilt/repository"
"github.com/retr0h/go-gilt/util"

"github.com/retr0h/go-gilt/internal/repository"
"github.com/retr0h/go-gilt/internal/util"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions git/git_public_test.go → internal/git/git_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
"path/filepath"
"testing"

"github.com/retr0h/go-gilt/git"
"github.com/retr0h/go-gilt/repository"
"github.com/retr0h/go-gilt/test/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/retr0h/go-gilt/internal/git"
"github.com/retr0h/go-gilt/internal/repository"
"github.com/retr0h/go-gilt/test/testutil"
)

type GitTestSuite struct {
Expand Down
5 changes: 3 additions & 2 deletions git/git_test.go → internal/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
"fmt"
"testing"

"github.com/retr0h/go-gilt/repository"
"github.com/retr0h/go-gilt/test/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/retr0h/go-gilt/internal/repository"
"github.com/retr0h/go-gilt/test/testutil"
)

type GitTestSuite struct {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
"strings"

"github.com/ghodss/yaml"
"github.com/retr0h/go-gilt/git"
"github.com/retr0h/go-gilt/repository"
"github.com/xeipuuv/gojsonschema"

"github.com/retr0h/go-gilt/internal/git"
"github.com/retr0h/go-gilt/internal/repository"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
"path"
"testing"

"github.com/retr0h/go-gilt/git"
"github.com/retr0h/go-gilt/repositories"
"github.com/retr0h/go-gilt/test/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/retr0h/go-gilt/internal/git"
"github.com/retr0h/go-gilt/internal/repositories"
)

type RepositoriesTestSuite struct {
Expand Down Expand Up @@ -113,7 +114,7 @@ func (suite *RepositoriesTestSuite) TestUnmarshalYAMLFileReturnsErrorWithMissing
}

func (suite *RepositoriesTestSuite) TestUnmarshalYAMLFile() {
suite.r.Filename = path.Join("..", "test", "gilt.yml")
suite.r.Filename = path.Join("..", "..", "test", "gilt.yml")
err := suite.r.UnmarshalYAMLFile()
assert.NoError(suite.T(), err)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import (
"testing"

"github.com/ghodss/yaml"
"github.com/retr0h/go-gilt/test/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/xeipuuv/gojsonschema"

"github.com/retr0h/go-gilt/test/testutil"
)

type RepositoriesTestSuite struct {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import (
"strings"

"github.com/logrusorgru/aurora"
"github.com/retr0h/go-gilt/util"

"github.com/retr0h/go-gilt/internal/util"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import (
"path/filepath"
"testing"

"github.com/retr0h/go-gilt/git"
"github.com/retr0h/go-gilt/repositories"
"github.com/retr0h/go-gilt/repository"
"github.com/retr0h/go-gilt/test/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/retr0h/go-gilt/internal/git"
"github.com/retr0h/go-gilt/internal/repositories"
"github.com/retr0h/go-gilt/internal/repository"
"github.com/retr0h/go-gilt/test/testutil"
)

type RepositoryIntegrationTestSuite struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
"path/filepath"
"testing"

"github.com/retr0h/go-gilt/repository"
"github.com/retr0h/go-gilt/test/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/retr0h/go-gilt/internal/repository"
"github.com/retr0h/go-gilt/test/testutil"
)

type RepositoryTestSuite struct {
Expand Down
3 changes: 2 additions & 1 deletion util/util.go → internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import (
"strings"

"github.com/logrusorgru/aurora"
"github.com/retr0h/go-gilt/io"

"github.com/retr0h/go-gilt/internal/io"
)

var (
Expand Down
15 changes: 8 additions & 7 deletions util/util_public_test.go → internal/util/util_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import (
"testing"

capturer "github.com/kami-zh/go-capturer"
"github.com/retr0h/go-gilt/util"
"github.com/stretchr/testify/assert"

"github.com/retr0h/go-gilt/internal/util"
)

func TestPrintError(t *testing.T) {
Expand Down Expand Up @@ -93,8 +94,8 @@ func TestRunCommandPrintsStreamingStderr(t *testing.T) {
}

func TestCopyFile(t *testing.T) {
srcFile := path.Join("..", "test", "resources", "copy", "file")
dstFile := path.Join("..", "test", "resources", "copy", "copiedFile")
srcFile := path.Join("..", "..", "test", "resources", "copy", "file")
dstFile := path.Join("..", "..", "test", "resources", "copy", "copiedFile")
err := util.CopyFile(srcFile, dstFile)
defer func() { _ = os.Remove(dstFile) }()

Expand All @@ -103,16 +104,16 @@ func TestCopyFile(t *testing.T) {
}

func TestCopyFileReturnsError(t *testing.T) {
srcFile := path.Join("..", "test", "resources", "copy", "file")
srcFile := path.Join("..", "..", "test", "resources", "copy", "file")
invalidDstFile := "/super/invalid/path/to/write/to"
err := util.CopyFile(srcFile, invalidDstFile)

assert.Error(t, err)
}

func TestCopyDir(t *testing.T) {
srcDir := path.Join("..", "test", "resources", "copy", "dir")
dstDir := path.Join("..", "test", "resources", "copy", "copiedDir")
srcDir := path.Join("..", "..", "test", "resources", "copy", "dir")
dstDir := path.Join("..", "..", "test", "resources", "copy", "copiedDir")
err := util.CopyDir(srcDir, dstDir)
defer func() { _ = os.RemoveAll(dstDir) }()

Expand All @@ -121,7 +122,7 @@ func TestCopyDir(t *testing.T) {
}

func TestCopyDirReturnsError(t *testing.T) {
srcDir := path.Join("..", "test", "resources", "copy", "dir")
srcDir := path.Join("..", "..", "test", "resources", "copy", "dir")
invalidDstDir := "/super/invalid/path/to/write/to"
err := util.CopyDir(srcDir, invalidDstDir)

Expand Down
File renamed without changes.

0 comments on commit 0bb3da1

Please sign in to comment.