New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor-x, closes #373 #386
Changes from 3 commits
725db2f
433fbd1
3d8e666
18c99ce
3637046
8ad6e0f
c375f68
05dbb78
f784c31
5c5953d
7101360
8711a71
bf9e226
83c4bc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,8 @@ plugins: | |
enabled: true | ||
govet: | ||
enabled: true | ||
|
||
checks: | ||
return-statements: | ||
config: | ||
threshold: 6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
|
||
"github.com/mesg-foundation/core/service" | ||
"github.com/stretchr/testify/require" | ||
git "gopkg.in/src-d/go-git.v4" | ||
) | ||
|
||
func TestDefaultPath(t *testing.T) { | ||
|
@@ -20,33 +19,6 @@ func TestBuildDockerImagePathDoNotExist(t *testing.T) { | |
require.NotNil(t, err) | ||
} | ||
|
||
func TestGitCloneRepositoryDoNotExist(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should keep these tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed my mind, no need this here but got to put equivalent to xgit. and mock underlying git package if possible. we need these tests to see if we call git.PlainClone() with the right args. |
||
path, _ := createTempFolder() | ||
defer os.RemoveAll(path) | ||
err := gitClone("/doNotExist", path, "testing...") | ||
require.NotNil(t, err) | ||
} | ||
|
||
func TestGitCloneWithoutURLSchema(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should keep these tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed my mind, no need this here but got to put equivalent to xgit. and mock underlying git package if possible. we need these tests to see if we call git.PlainClone() with the right args. |
||
path, _ := createTempFolder() | ||
defer os.RemoveAll(path) | ||
err := gitClone("github.com/mesg-foundation/awesome.git", path, "testing...") | ||
require.Nil(t, err) | ||
} | ||
|
||
func TestGitCloneCustomBranch(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should keep these tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed my mind, no need this here but got to put equivalent to xgit. and mock underlying git package if possible. we need these tests to see if we call git.PlainClone() with the right args. |
||
branchName := "5-generic-service" | ||
path, _ := createTempFolder() | ||
defer os.RemoveAll(path) | ||
err := gitClone("github.com/mesg-foundation/service-ethereum-erc20#"+branchName, path, "testing...") | ||
require.Nil(t, err) | ||
repo, err := git.PlainOpen(path) | ||
require.Nil(t, err) | ||
branch, err := repo.Branch(branchName) | ||
require.Nil(t, err) | ||
require.NotNil(t, branch) | ||
} | ||
|
||
func TestDownloadServiceIfNeededAbsolutePath(t *testing.T) { | ||
path := "/users/paul/service-js-function" | ||
newPath, didDownload, err := downloadServiceIfNeeded(path) | ||
|
@@ -72,19 +44,6 @@ func TestDownloadServiceIfNeededUrl(t *testing.T) { | |
require.Equal(t, true, didDownload) | ||
} | ||
|
||
func TestCreateTempFolder(t *testing.T) { | ||
path, err := createTempFolder() | ||
defer os.RemoveAll(path) | ||
require.Nil(t, err) | ||
require.NotEqual(t, "", path) | ||
} | ||
|
||
func TestRemoveTempFolder(t *testing.T) { | ||
path, _ := createTempFolder() | ||
err := os.RemoveAll(path) | ||
require.Nil(t, err) | ||
} | ||
|
||
func TestInjectConfigurationInDependencies(t *testing.T) { | ||
s := &service.Service{} | ||
injectConfigurationInDependencies(s, "TestInjectConfigurationInDependencies") | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package utils | ||
|
||
// TempDirPrefix is a prefix for temp dirctories or files. | ||
const TempDirPrefix = "mesg-" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
package service | ||
|
||
import ( | ||
"github.com/cnf/structhash" | ||
) | ||
import "github.com/mesg-foundation/core/x/xstructhash" | ||
|
||
// Hash calculates and returns the hash of the service. | ||
func (service *Service) Hash() string { | ||
// Ignore the err result because the lib always return nil | ||
hash, _ := structhash.Hash(service, 1) // TODO: why not reuse the package utils/hash? | ||
return hash | ||
return xstructhash.Hash(service, 1) | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not valid, the
\n
create some problems with the spinner. We should never use a\n
when it's a message for the spinnerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done